Asked 30+ days ago
22 May 2017
Views 135
sachin

sachin posted

how to use ajax in Wordpress ?



 function print_state(){
 
 var e = document.getElementById("country");
var strUser = e.options[e.selectedIndex].value;

var data="searchby=" + strUser+"&action=getState";

 jQuery.ajax({
 url:url,
 type: "POST",
 dataType:'html',
 data: data,
 success: function(data)
 {

  jQuery('#state').html(data);

 }
 });
}


above is simple code for getting list of the state from the country .
used jQuery for ajax but how to implement with wordpress ? how to make server side file which respond to ajax request . and how to embed ajax javascript to Wordpress front page ?

Post Answer