John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

reading service response

Hi, i have a REST service response like this:

{
"result":"pass",
"errorcode":"0",
"body":""
}

and the result will be either 'pass' or 'fail'

and i thought i can write a JS like this:

---------------------------------------------------------------------------------------------

if(result == pass) {
$.mobile.changePage("changes_saved.html", {transition: "pop"});
}
else {
$.mobile.changePage("changes_not_saved.html", {transition: "pop"});
}

-----------------------------------------------------------------------------------------------

but im getting an error in firebug:

ReferenceError: result is not defined

whats wrong with this JS?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

reading service response

Where do you have this JS?
Please tell steps to reproduce.

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

reading service response

ohh ok, im running this JS on success of Invoking a service inside the DataTab.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

reading service response

You have to define variable 'result'

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

reading service response

how do you define a variale in a service response? Like the one i have here:

{
"result":"pass",
"errorcode":"0",
"body":""
}

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

reading service response

You should use 'success' callback to get the data from 'data' variable: http://docs.appery.io/documentation/a...

Return to “Issues”