PDA

View Full Version : Ajax value response, to run a certain function



shinkiwink
08-28-2008, 01:27 AM
I am very good at getting ajax to respond data from a php file and input that data into a certain div, but what im having problems with is coding an ajax response that will grab a value from a php file, then depending on that value ---- ajax will run a certain function i have specified.

Something like this

1) Ajax gets checkmsg.php?response=msgtrue
2) Ajax reads the data(or output) from the php file (for example the response might be msgtrue)
3) Ajax takes the value returned from php and runs some function
4) that function runs and does what i specify it to do!

Simply Put

--- Ajax Request ----
---PHP data returned to ajax ---
---Ajax runs a function depending on php repsonse ---
---User sees the function ---

i was trying to write a if statement in javascript, that states

if (phpdata=msgtrue)
{
launch_some_function();
}

Nile
08-28-2008, 02:49 AM
I think it should be this:


if (phpdata == msgtrue)
{
launch_some_function();
}

mburt
08-28-2008, 02:52 AM
Yep, shinkiwink was assigning a value, not comparing one.

Nile
08-28-2008, 02:57 AM
Yep, shinkiwink was assigning a value, not comparing one.

I know, thats why I corrected him. :)

shinkiwink
08-28-2008, 07:22 PM
thanks so much for the response i actually figured it out 15 minutes after i posted this. And that = sign i actually meant to put == in the first place. Guys thanks so much.