Q: How to detect a response which does not have an object Complete newbie question :
When I query to database using API, I sometimes get a response which contains no objects.
With the code below no alerts are raised at all.
I need a method to detect this type of empty response - jQuery.isEmptyObject does not work.
$.get("http://api.lmiforall.org.uk/api/v1/ashe/estimatePay",
{ soc: soc, coarse: "false", filters:"region:12"},
function(datani) {

alert(datani);

if(jQuery.isEmptyObject(datani)) {
alert("empty");

}


A: use done event to identify.
 <script>
    $.get( "test.php", { name: "John", time: "2pm" } )
        .done(function( data ) {
            alert( "Data Loaded: " + data );
    });
</script>


A: It sounds like you are confusing no response as being an empty object.
Something like:
var myObj = {};

would be considered an empty object that isEmptyObject() would return true for but an empty string (no response) would not
Try changing:
if(jQuery.isEmptyObject(datani)) {

To
if(!datani) {


A: 
With the code above no alert box appears at all.

The first alert() should be called; whether response is object or not.
You can add error handling to ajax request using .fail() to alert textStatus, errorThrown or property of jqxhr object.
Note, also js at Question is missing closing }) at $.get() . 
$.get("http://api.lmiforall.org.uk/api/v1/ashe/estimatePay",
  { soc: soc, coarse: "false", filters:"region:12"},
  function(datani) {
    alert(datani);
}).fail(function(jqxhr, textStatus, errorThrown) {
    alert(textStatus + " " + errorThrown)
})

