How To Display Alert Box When No Json Value Is Given
I have displayed the result of a SPARQL query in a HTML page using Json, my question is when a certain value is entered and the query does not display a result it should display a
Solution 1:
You can do this several different ways:
If bindings
is a constant of your object, but may sometimes be empty:
if (data.results.bindings.length) {
//exists
} else {
alert('goes here');
}
If bindings
is not always set in the response from the server:
if (data.results.hasOwnProperty('bindings')) {
//exists
} else {
alert('goes here');
}
Post a Comment for "How To Display Alert Box When No Json Value Is Given"