开发者

How do I call a php function with a jquery ajax call? [duplicate]

This question already has answers here: Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜