jQuery Ajax
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)
})
/**
* 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')
});
}