Jump to content

Quick question regarding the open() function in AJAX


sleepydude
 Share

Recommended Posts

Hello, I'm pretty new to all this development stuff and I've got a question regarding the open() step in writing a AJAX function. Say I have a document "example.php" which contains two functions "function1()" and "function2()". When I get to the step,ajax_variable.open("GET", "example.php", true); is there any way of specifying which function should be used from example.php? Thanks

Link to comment
Share on other sites

It has nothing to do with the 'open' step. The data in your get query string is sent to the server in the 'send' step, in a JS command like this: xmObj.send (myData). I'm assuming you can construct and parse a query string in the appropriate places? If not, post again.

Link to comment
Share on other sites

Well you could have a GET parameter that defines what function to use. E.g.phppage.php

<?phpif ($_GET['function'] == "function1") function1();if ($_GET['function'] == "function2") function2();?>

Then if you want to run function1 you call phppage.php?function=function1

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...