Skip to content

Instantly share code, notes, and snippets.

@pbrocks
Created November 2, 2017 15:32
Show Gist options
  • Save pbrocks/11a2c824e79bb78f5c5471e6d60064ae to your computer and use it in GitHub Desktop.
Save pbrocks/11a2c824e79bb78f5c5471e6d60064ae to your computer and use it in GitHub Desktop.
JS as part of AJAX call
jQuery(document).ready(function($) {
$('#location_select_submit').click(function() {
$.ajax({
type: "POST",
url: location_select_script.location_select_ajaxurl,
data: {
// Variables defined from form
action : 'location_select_action',
serialize : $('#location-select-form').serialize(),
custjson : $('#custjson').val(),
custnumber : $('#custnumber').val(),
selected : $('#selected-location').val(),
// Admin stuff
script_name : 'if-location-select.js',
ajaxurl: location_select_script.location_select_ajaxurl,
nonce : location_select_script.location_select_nonce,
},
success:function( data ) {
// $('#location-select-response').html( data );
$('#location_select_response').html( data );
$('#location-select-contacts').html( data );
// console.log(data);
},
error: function(){
console.log(errorThrown);
}
});
});
});
@pbrocks
Copy link
Author

pbrocks commented Nov 2, 2017

This is the latest iteration of the JS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment