0

I have a selectbox that needs to be updated dynamically. I am using jquery to perform that using .load($url), where $url is the location of the php file to call. I am wondering if there is a way to call a specific function within that php file instead of calling the entire php file.

1
  • 3
    I don't believe there is, sorry. You are effectively opening a web page and capturing the output. I don't think there's anyway from a URL to cause a specific PHP function to be executed within a collection of functions contained with a 'page' without you writing code within the page to broker that interaction. Commented Aug 10, 2010 at 15:20

3 Answers 3

3

You could send a GET parameter as part of the AJAX request e.g. blah.php?func=1

Then in your PHP file:

if ($_GET['func'] == 1) {
    do_something();
}
else {
    do_something_else();
}

Or you could use something like CodeIgniter that structures its URL's as controller/function/parameter

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

Comments

0

no, you can't. but you can pass GET parameters to the URL, and use that URL as a controller. for example:

.load("/ajax_controller.php?action=whatever")

Comments

0

You can pass a parameter to PHP script and user switch in script to select which action needs to be done

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.