0

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 call instead of calling the whole URL?

0

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.