Before, I was using sajax to call php functions if I need to call it with ajax. Now I prefer to switch to jquery. How is possible to call a php function with jquery?
What do you mean with “ajax”? With vanilla JavaScript?
With JQuery you would do something like this:
$.ajax({
type: "POST",
url: "some.php",
data: { name: "John", location: "Boston" }
})
.done(function( msg ) {
alert( "Data Saved: " + msg );
});
JQuery is still JavaScript, only shorter. In fact, JQuery is a JavaScript library.
You can check out the documentation here: https://api.jquery.com/jQuery.ajax/
yep do what xMog says.
If you want to call a specific function you could pass a value along to determine which function to call e.g.
$.ajax({
type: "POST",
url: "some.php",
data: { function_to_call: "update_the_db"}
}));