Page 2 of 5

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

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

and without that line code (looks like this):

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

I get an error as well:

Image


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

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

so in either case, theres an error. I have no idea what that error is.... please help..??


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

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

heres the error if you have trouble viewing the pic:

TypeError: element is undefined
[Break On This Error]

locked: function() {


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

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

Image 2, original post, you are setting this:

code
localStorage.setItem('id', g)
/code

but there is no 'g' variable in the function.

The function gets passed 'value' (the actual value from from the service) and 'element' (UI component).

You should use 'value'. But you don't need to do that at all, just by mapping, the value will be set.

It's described in the docs: http://docs.appery.io/documentation/a...


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

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

ok well if i delete the JS for that one, and leave the JS on the one sending back to the server - i still get an error because when im submitting that page the server, its missing the value necessary to complete the submit_load service. The server returns back a false. I need a true response from the server


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

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

this popup represents a false response from the server. So im still not passing the selected item from the select menu..

Image


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

Posted: Fri May 24, 2013 2:00 am
by John Herdean

ok, well as i can tell after reading the documentation, i think my JS code is probably wrong. I deleted the the 1st JS since your saying by default by mapping it will be stored. Now, to return a value back to the server, my revised code looks like this:

localStorage.setItem('id, 'driver_name');
return id.toUpperString();

Please tell me whats wrong with this code?


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

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

i guess its supposed to be a getItem... i changed it, but still nothing has changed. And to be honest, I found the line code: return value.toUpperString();

in your documentation, but im not even sure what ...toUpperString(); means. I rewrote it like this and i still dont get it to work:

localStorage.getItem('id', 'driver_name');
return id;

so, can i get some help on this code?


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

Posted: Fri May 24, 2013 3:41 am
by maxkatz

toUpperString() is a JavaScript function that converts string to all upper case. It's used as an example, you don't need to use it.

There is no method localStorage.getItem('id', 'driver_name'). It should be setItem. To get an item, you should use:

localStorage.setItem(key, value)

Local storage (and toUpperCase) is standard JavaScript browser API. I highly recommend you review it here: https://developer.mozilla.org/en-US/d...


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

Posted: Fri May 24, 2013 3:42 am
by Illya Stepanov

Hi John - is there any errors in console with this changes?