Quick question:
I'm using jquery ajax to call a page that returns some json data. Sometimes it returns full of data and sometimes it returns empty as []
.
I want the script to do different things if it comes back empty[]
or with data. Everything is working fine when it returns with data, but I can't seem to get things to work when it returns empty as []
. Here's what i have:
success: function (returndata){
if (returndata === null)
{
$("#versionBox").remove();
}
else {
$.each(returndata, function()
{
var tag = this["name"];
var linkname = "textdisplay.php?flag=<?php echo $fs; ?>&ed=" + tag;
$('#versionBox').append("<p><a href='" + linkname + "'>" + tag + "</a></p>");
});
}
But null
doesn't seem to be the correct way to describe []
because the first part of this script isn't working.
Thanks for your advice.