Slim81
asked on
Jquery and $.ajax, how to retrieve data from POST...
Hey Guys and Gals,
I am finally stepping into the world of Ajax and I have a question.... How do I grab values that are returned from a script the javascript POSTed to?
This is what I am trying to do:
I have a 'Promo Code' field and want to check to see if the promo code is valid. The javascript (JQuery) will post to my script and then send some data back (example: the Promotion Name that is tied to the promo code).
Here is some generic code, check the commented code for my issues...
Thanks for the help!
I am finally stepping into the world of Ajax and I have a question.... How do I grab values that are returned from a script the javascript POSTed to?
This is what I am trying to do:
I have a 'Promo Code' field and want to check to see if the promo code is valid. The javascript (JQuery) will post to my script and then send some data back (example: the Promotion Name that is tied to the promo code).
Here is some generic code, check the commented code for my issues...
$.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
}).done(function( msg ) { //---- It looks like 'msg' is the returned value from the some.php script.
alert( "Data Saved: " + msg );
//How do I send 'msg' from the some.php file back to my requesting page? Should 'msg' be a javascript variable in some.php?
});
Thanks for the help!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Brilliant. JQuery has made ajax easy for me to understand.
ajax rocks.
Thanks for your help!
ajax rocks.
Thanks for your help!
ASKER
Thanks for the reply.
Anything that the browser would display?
In the example I provided (pulled from the JQuery website), they use the variable/parameter of 'msg' in the '.done' function. Do I have to reference or create 'msg' on the some.php file or am I free to name that variable/parameter whatever I want?
Thanks!