I am creating small plugin where i want to submit form data using ajax but it giving response zero.
Here is my call i have added all code in a single file for the time being
file name :index.php
jQuery(document).ready(function(){
jQuery(‘#shaGalleryForm’).submit(function(e){
// prevent normal submit behaviour
e.preventDefault();
var name = jQuery(“#shaGalleryName”).val();
alert(name);
//var postData = jQuery(“#shaGalleryForm”).serialize();
//console.log(postData);
var name = “shalu”;
jQuery.ajax({
type: “POST”,
url: “http://localhost/plugindevelop/wp-admin/admin-ajax.php”,
data : {action: “myaddgallery”, name : name},
success: function(response){
//console.log(postData);
console.log(“added success”);
alert(response);
},
error: function(data){
console.log(“fail”);
}
});
});
}) ;
Add Gallery
This is where from you can create new gallery
Gallery Name
Add gallery name also please avoid special character
Read more here: How to submit form using ajax inside wordpress plugin