I have a function like this:
$.getJSON('<?php echo site_url('get_leads/main_contact'); ?>',
function(data) {
...
});
It works fine. But sometimes there is no data coming back from the server? How do I detect if the JSON object is empty? I tried “if(data == ”)” and it didn’t work.
Use jQuery.isEmptyObject
This will at least capture an empty array, an empty object, null and undefined.