Possible Duplicate:
using jquery $.ajax to call a PHP function
I need to call a specific php function within my php file. Is there any way to point to that function with jquery ajax cal开发者_如何转开发l instead of calling the whole URL?
Without a PHP framework, here are some ways to do it:
1 - Put the function in its own file.
2 - Put a wrapper function in its own file: all it does is #require your file, then call your desired function.
3 - Create one file that handles ajax (that'll be the entry point). Then pass a choice of functions using GET. Something like ajax_handler.php?fn=MyFunction
Nope. You may need to factor out the function. Place it in a separate file and have it echo
a JSON response or whatever you see fit when it is being called via Ajax
You can try if the following StackOverflow question answers your query:
jQuery: Return data after ajax call success
using jquery $.ajax to call a PHP function
Also, some more information on what exactly and why do you wish to get such a functionality might be useful.
精彩评论