Page 1 of 5

how to pass data from an incoming json response to local storage, then back to my server?

Posted: Fri May 24, 2013 12:45 am
by John Herdean

hi, Im first populating a selectmenu from a json list, then i want to store the value the user selected in local storage, then i want to use that value to send back to the server along with other elements. I'm using the following codes:

This code to grab from the json response and store the value:

Code: Select all

         localStorage.setItem('id',g); 

And this code to send back to the server:

Code: Select all

       var g=localStorage.getItem('id'); 

Are these the right codes to do this?

see below for snapshots:

Image Image Image Image

This is the Resulting Page, its now not even loading the select menu anymore, its crashing on arrival (its frozen with the progress bar keep running)...


how to pass data from an incoming json response to local storage, then back to my server?

Posted: Fri May 24, 2013 12:45 am
by John Herdean

how to pass data from an incoming json response to local storage, then back to my server?

Posted: Fri May 24, 2013 12:54 am
by maxkatz

The code looks fine but none of the images are showing...


how to pass data from an incoming json response to local storage, then back to my server?

Posted: Fri May 24, 2013 12:59 am
by John Herdean

thats strange because i can see them on my screen no problem, try my link:

https://getsatisfaction.com/apperyio/...


how to pass data from an incoming json response to local storage, then back to my server?

Posted: Fri May 24, 2013 1:00 am
by maxkatz

It's fine now.


how to pass data from an incoming json response to local storage, then back to my server?

Posted: Fri May 24, 2013 1:01 am
by John Herdean

and i uploaded them as usual...


how to pass data from an incoming json response to local storage, then back to my server?

Posted: Fri May 24, 2013 1:01 am
by maxkatz

Check if there are any error in the console.

In mapping, you need to do:

code
...
return g;
/code


how to pass data from an incoming json response to local storage, then back to my server?

Posted: Fri May 24, 2013 1:02 am
by John Herdean

well if the codes are good, then that means somehow i didnt map them right or something else. i did everything exactly as shown in your tutorial. i thought this instruction was very straight forward..


how to pass data from an incoming json response to local storage, then back to my server?

Posted: Fri May 24, 2013 1:11 am
by John Herdean

can you be more specific? where does that line go?


how to pass data from an incoming json response to local storage, then back to my server?

Posted: Fri May 24, 2013 1:16 am
by John Herdean

well i added that line to the code that sends back and the final looks like this:

var g=localStorage.getItem('id');
return g;

and heres the error with this code: Image