I am trying to store json data returned by the $.ajax() function, but am having trouble. Below is the call I make (which I know returns my JSON data properly, I have logged it (url removed for personal reasons).
$.ajax({
type: "GET",
url: **url that returns json data**
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
return msg;
},
error: function(e){
WL.Logger.log(e);
}
});
And then I initialize my JSONStore using worklight:
//Setup JSON store
var collectionName = 'people';
//Object that defines all the collections
var collections = {};
//Object that defines the 'people' collection
collections[collectionName] = {};
WL.JSONStore.init(collections);
So now here is where I am having my issue. I want to add the JSON data I am returning from my ajax call to my JSONStore. So I have attempted this (getJSONData is a wrapper around the ajax call above):
WL.JSONStore.get(collectionName).add(getJSONData());
However, when I print the collection, nothing is stored in it, and when I print WL.JSONStore.get(collectionName).count, nothing is returned. How can I add the data returned to me properly?