What I am looking to do is pull two to three DIFFERENT variables from this page. I am not sure this is at all possible, I read about .post and can only find it returning .data which is the HTML output of the entire script. What if I wanted to return: 1) success,success update message, success html 2) database error (duplicate), fail update message, fail update html 3) database error, (unknown database error - returned value), fail update html

My PHP will return either 1, 2, or 3. Either way it will return 3 variables. How do I pass this to my JQuery that originally posted the form? Is it at all possible?

-- Zak

jamie

2:23 pm on Feb 1, 2012 (gmt 0)

hi zak,

put the php results in array format, then you can use json_encode() on it and return that.

you may find it easier to use $.ajax() instead of $.post() whilst learning as it forces you to write the parameters in longhand.

as long as you set the dataType as 'json', the data object which is returned is a json object. so if your original php array was array('result' => 'OK') then data.result contains OK.