Created
April 15, 2018 14:24
-
-
Save keks55/24924eb1b7ae3d427d9d9dcdf0efe59a to your computer and use it in GitHub Desktop.
send wordpress ajax with form serialize
This file contains 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
$(".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