Created
January 4, 2019 03:19
-
-
Save crowdfundhq/f34044cf5604c0dea368964cdeb5d801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
window.hq.postDialog = function(form){ | |
var params = hq.serialize(form); | |
var center = hq.initDialog(); | |
window.hq.post(form.action, center, params); | |
}; | |
// General post ajax method | |
window.hq.post = function(url, el, params){ | |
if(!el){ el = document.getElementById('content');} | |
hq.ajax(url, { | |
method:'post', | |
data: params, | |
success: function(data){ | |
if(data === ''){ | |
// Redirect based on the response and where you came from | |
var redirect = cookies.get('redirect'); | |
if(redirect){ | |
window.location.href = redirect; | |
} else { | |
window.location.reload(true); | |
} | |
} else if(data[0] === '/'){ | |
// Redirect to URL | |
// window.location.replace(data); | |
window.location.reload(true); | |
} else { | |
// No redirect, just update current page | |
el.innerHTML = data; | |
if(!dialogOpen()){ scrollTo(0, 0)}; | |
loadScripts(); | |
} | |
} | |
}); | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment