I'm using Ajax/jsonp to access a remote database. As such, the response.error is never returned. I'm trying to catch an instance when the remote server does not return data for whatever reason. I've tried everything I can think of to catch an undefined condition and I can't seem to catch it. I've tried to find the variable with Firebug. I've tried using just about every combination of the following code I can think of and just can't seem to get it to work.
if ( typeof(data.flightStatuses[0].operationalTimes.publishedDeparture.dateLocal) === "undefined") {
alert("flightstats is undefined");
}
Any ideas greatly appreciated!!!!
I also tried:
if ( typeof data.flightStatuses === "undefined") {
alert("flightstats is undefined");
}
Above code won't execute alert either....
FINALLY! This worked...
if ( typeof data.flightStatuses[0] === "undefined")
I don't really know why, but it did. thanks your everyone's help!
data,flightStatuses,operationalTimesorpublishedDepartureare also undefined?=== undefinedis pretty safe. Additionally,typeofis an operator, not a function so you can omit the()