I have a PHP function on my site which takes a couple of seconds to complete. This holds the whole page up which I don't want.
Would it be possible with jquery to call this PHP function after the page has loaded and display the results in a div? Also to display an ajax loader image until the PHP function has completed?
I've been looking at jQuery.post but can't seem to get it to work.
Would someone be able to help?
Thank you
Also, apart from doing this with the click of a button, a PHP function can be called using Ajax, JavaScript, and JQuery.
You can call PHP function through Javascript by passing the value, you need as output of PHP function as a string in Javascript.
If I understand correctly, yes you can. Put all your functions in one php file and have the ajax pass as a parameter which one you want to call. Then with a switch or if structure, execute the one you want. Save this answer.
To call a function from another file in PHP, you need to import the file where the function is defined before calling it. You can import a PHP file by using the require statement. To call the greetings() function from another file, you need to import the library.
AJAX does the magic:
$(document).ready(function(
$.ajax({ url: 'script.php?argument=value&foo=bar' });
));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With