Skip to content

Instantly share code, notes, and snippets.

@puiutucutu
Last active October 26, 2015 16:46
Show Gist options
  • Save puiutucutu/2309921fe9df9699fdfc to your computer and use it in GitHub Desktop.
Save puiutucutu/2309921fe9df9699fdfc to your computer and use it in GitHub Desktop.
jQuery Ajax
/**
* hardcoded and rigid
*/
function ajaxGeocode(data) {
requestAJAX = jQuery.ajax({
method: 'POST',
url: 'php/ajax/geocode.php',
dataType: 'json',
data: { ajax : data }
});
requestAJAX.done(function(response) {
debug(response)
});
requestAJAX.fail(function(response) {
console.log('ajax failure')
});
}
function ajaxGeocode(data) {
return jQuery.ajax({
method: 'POST',
url: 'php/ajax/geocode.php',
dataType: 'json',
data: { ajax : data }
});
}
/**
* handle ajax response (in another part of the code structure)
*/
ajaxGeocode(addressInformation).done(function(response) {
debug('RESPONSE IS:')
debug(response)
}).fail(function(response) {
debug('Error has occurred: ' response)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment