-3

Possible Duplicate:
Call PHP Function using jQuery AJAX

I have a PHP file containing all functions created by me. I just want to know, how can I call a specific function through Ajax?

2
  • I'm not sure what you mean with this. You can only AJAX call a URL. You would need to have the functions at a separate URL or use some MVC framework to map them Commented Jan 28, 2013 at 11:01
  • If you have a different URL for each of the methods, you can call those urls to call the methods associated with them Commented Jan 28, 2013 at 11:02

3 Answers 3

1

You could pass a get or post variable and use it to then using php call a specific function. WHat exactly are you trying to achieve ?

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

Comments

0

send the function name through GET method to the php page and then execute _GET value using call_user_func

http://php.net/manual/en/function.call-user-func.php

Comments

0

You could use call_user_func():

$name = $_POST['function'];

if (in_array($name, $allowed_functions)) {
    $result = call_user_func($name);
}

Although this reeks of bad design. Why do you need to do this?

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.