I am new to using Dojo framework. I have implemented dgrid for collecting data and this works great for storing, querying, updating and deleting data from the client side during data entry. However once the dojo.store.memory data type has data i would like to use an ajax request to post the dojo object to the server.
I would like to post the data to the server in json format however i am unable to convert the object (myStore) to json string. Under is what i have attempted thus far:
JavaScript function
function SendForm(){
var jsonIdObj = JSON.stringify(myStore);
dojo.xhrPost({
url:'processData',
form:dojo.byId('myForm'),
postData:jsonIdObj,
success: function(){
console.log('success');
},
error: function(){
console.log('error occured');
}
});
}
Data Store
var myStore = new dojo.store.Observable(new Memory({data: data, idProperty:"typeId"}));
Data
var data = [{ id:"1",age:"33",idtype:"1" ,first_name: "Edward", surname: "Davis" },
{ id:"2",age:"41",idtype:"2" ,first_name: "Lewis", surname: "Holl"},
{ id:"3",age:"59",idtype:"3" ,first_name: "Fred", surname: "James"}];