javascript - Why wont my JSON.stringify() work with localstorage.setItem()? -


I have an object drawn from a form on my page. I press this object in an array.

  var postObj = {title: $ ('input'). Val (), body: $ ('textarea') Val ()} postArray.push (postObj); Localstorage.setItem ("Post", JSON.stringify (postArray));   

However, I'm just getting an unicode reference error: local storage is not defined .

I get this response in the console [object body: "dog" title: "title" __proto__: object] JSON.stringify (postArray) [object body: title "dog", "title", Body: "dog"} posterior [title]; "[" Title: "title", "body": "dog"}] "

I get most of the answers to those questions which say to use JSON Stringify (array) . I do not know that when I use the JSON.stringify data parameter of .setItem then it does not work

It seems that you have a typo, it should be: < P> window.localStorage // Note that the name of camel cas

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -