posting an array of json using dojo
Hi I am trying to post an array of javascript objects back to the server, using dojo.
I have an array of data that is like appears like this:
var elements = [
myobj = {id:"1", name:"myname", title:"mytitle"},
myobj = {id:"2", name:"myname2", title:"mytitle2"}
]
I want to post this as a json string back to the server to be handled by a PHP script. However d开发者_如何学JAVAojo.toJson will only seralise an individual object.
How can I convert the entire array of objects into a json string that can be posted to the backend for processing?
many thanks
You are misinformed: dojo.toJson()
handles arrays without a problem. I just plugged in your elements
and that's what I've got:
[{"id":"1","name":"myname","title":"mytitle"},{"id":"2","name":"myname2","title":"mytitle2"}]
Looks okay to me.
But maybe I misunderstood something? Please post a sample proving your point.
精彩评论