function submit_onClick() {
var addValue = jQuery("#billing_address_1").val();
jQuery.ajax({
type: "POST",
url: "http://localhost/wordpress/wp-admin/admin-ajax.php",
data: {'action':'distance_calculation', addValue:addValue}
}).done(function(data) {
alert(data);
});
}
this works fine until I dont place distance_calculation inside any class. how can i call a function if its inside any class for example, if distance_calculation function is inside any class called "distance" then how to call this in action .
Have the the ajax request like so
function submit_onClick() {
var addValue = jQuery("#billing_address_1").val();
jQuery.ajax({
type: "POST",
url: "http://localhost/wordpress/wp-admin/admin-ajax.php?method=distance_calculation&addValue=addValue"
}).done(function(data) {
alert(data);
});
}
Then in your PHP file add
if(strcmp($_POST["method"],"distance_calculation")){
$class->distance_calculation($_POST["addValue"]);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.