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

how to trigger a page to nativate to from a json response?

yes it is finally starting to work... I really appreciate you guys taking me by the hand here...

However, there is one last thing thats not working in this area: Theres 2 responses from the server: true or false. I entered some info on the live test app that must trigger a false, but it keeps on popping up the "load_submitted" when it should popup the "load_not_submitted" when the server returns a false. So, I dont know if theres an issue with the java script code i wrote or would it be something else?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

how to trigger a page to nativate to from a json response?

Hi John,

In Rest Service "submit_load" there is an only response parameter "response". If you want to navigate to another page depending on this parameter then you would need in action "Run JavaScript" for Rest Service replace the existing code with the following:
codeif(data.response=="true") {
$.mobile.changePage("load_submitted.html", {transition: "pop"});
}
else {
$.mobile.changePage("load_not_submitted.html", {transition: "pop"});
}/code

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

how to trigger a page to nativate to from a json response?

Hi, i tried that new code and still doesnt work. Same situation - i only get "load_submitted.html" to pop up regardless of a true or false response. Can you please review this again or check inside my app to see if there is anything else i am missing?

I even tried another variation, here are both final codes i tried:

Code #1:

var response = localStorage.getItem('submit_load2');

if(data.response=="true") {
$.mobile.changePage("load_submitted.html", {transition: "pop"});
}
else {
$.mobile.changePage("load_not_submitted.html", {transition: "pop"});
}

Code #2:

var response = localStorage.getItem('submit_load2');

if(data.response=="true") {
$.mobile.changePage("load_submitted.html", {transition: "pop"});
}
if(data.response=="false") {
$.mobile.changePage("load_not_submitted.html", {transition: "pop"});
}

Harold Gottschalk
Posts: 0
Joined: Wed Mar 27, 2013 9:42 pm

how to trigger a page to nativate to from a json response?

On code snippet 1 Have you tried the following if(data.response === true)

BTW var response = localStorage.getItem('submit_load2'); serves no purpose unless you are storing a value at some other point, but even if you are you are not using it in this code snippet.

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

how to trigger a page to nativate to from a json response?

Thank you Harold, that does work now...

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

how to trigger a page to nativate to from a json response?

the reason is because I am using strings

Return to “Issues”