I have this code sample which returns data in JSON format to put into slickGrid:
$.getJSON(url, function(data) {
$.each(data, function() { dataReturn.push(this); });
...
myDataView.setItems(dataReturn);
...
});
but I am looking for a synchronous way and I tried something like this:
var dataReturn = JSON.stringfy( $.ajax({url:"...", async: false }).responseText );
myDataView.setItems(dataReturn);
but seems it isn't really the same...what I have missed?
Thanks in advance Cheers Luigi
Use $.ajax and set async : false like this
$.ajax({
url:url,
dataType : 'json',
async : false,
success : function(data) {
$.each(data, function() { dataReturn.push(this); });
...
myDataView.setItems(dataReturn);
...
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With