Skip to content

Instantly share code, notes, and snippets.

@treykane
Last active December 17, 2015 15:48
Show Gist options
  • Save treykane/6623dcfda9d0397f846a to your computer and use it in GitHub Desktop.
Save treykane/6623dcfda9d0397f846a to your computer and use it in GitHub Desktop.
Parse and handle a basic AJAX response.
$.post("ajax_rope_check.php", { //FORM AJAX
street: s.step_two_street.val(),
city: s.step_two_city.val(),
state: s.step_two_state.val(),
zip: s.step_two_zip.val()
})
.done(function(response){ //AJAX RESPONSE
response = $.parseJSON(response);//CHANGE STR TO OBJ
if(response.serviceable === true) {
//IF TRUE DO NOTHING
}
else { //IF FALSE
s.step_three_not_serviceable.removeClass('is-hidden');
s.step_three_serviceable.addClass('is-hidden');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment