Last active
October 26, 2015 16:46
-
-
Save puiutucutu/2309921fe9df9699fdfc to your computer and use it in GitHub Desktop.
jQuery Ajax
This file contains hidden or 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
/** | |
* 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') | |
}); | |
} |
This file contains hidden or 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
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