Skip to content

Instantly share code, notes, and snippets.

@keks55
Created April 15, 2018 14:24
Show Gist options
  • Save keks55/24924eb1b7ae3d427d9d9dcdf0efe59a to your computer and use it in GitHub Desktop.
Save keks55/24924eb1b7ae3d427d9d9dcdf0efe59a to your computer and use it in GitHub Desktop.
send wordpress ajax with form serialize
$(".mgm-ajax-form").on("submit", function(e){
e.preventDefault();
var form = $(this);
ajax$.ajax({
action: "mgm_insert_marker",
type: "post",
url: ajaxurl,
data: form.serialize(),
//_ajax_nonce: $("#_wpnonce").val(),
beforeSend: function(){
$("#loading").appendTo("#load").fadeIn("fast");
$("#formstatus").fadeOut("slow");
},
success: function(html){
$("#loading").appendTo("#load").fadeOut("slow");
$("#formstatus").html(html).fadeIn("fast");
},
error: function(xhr){
console.log("Error: " + xhr.responseCode);
}
});
//return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment