PDA

View Full Version : Got Error by Reloading a Drig with no records in response



Nemesis_
16 Dec 2010, 8:26 AM
Hello... I have a little problem. I have a grid with a Json-Reader and if my PHP script returns records, all is fine, but sometime there are no records to deliver (for example: today are no events) and the i've got an exception "h is undefined" and if I use the ext-al-debug.js i could sea, that it is a little problem with the data reder. my responce string looks like:

{"data":[],"success":false}

I have an handler for such situations

Ext.Ajax.on("requestcomplete", function(oConnection, oResponse, oOptions) {
var oJson = Ext.decode(oResponse.responseText);
eval(oJson);

if (!oJson.success) {
alert('today no events found');
}
}

After my alert was shown, i got the discibed error and my question is: could i stop the reader to read "not existing data" in this handler above?

feyyaz
16 Dec 2010, 5:18 PM
your respond should be on an empty return not unsuccessfully

please post an succesfully respond with data, than i can show you how an empty one should look.

but a wild guess would be

{"data":[],"success":true}then you can check for an empty data array to show the alert.

Nemesis_
17 Dec 2010, 9:42 PM
I solved my problem. the answer was
{"success":false}
without any data