jQuery AJAX call not exiting when there is no response data -


i have following jquery code:

$.ajax({         url: application.common.relativepath + '/persons/search/',         contenttype: "application/json",         datatype: 'json',         // parameters name-value pairs passed         data: {             forename: forename,             surname: surname,             checkemployee: false         },         success: function(data) {             // no response data             if (!data) {                 return; // problem.             }              // code executed if there response.         }  }); 

when there no response data, ajax function should exit, hence use of return statement. however, finding if there no response data (data null), code below gets executed means return statement not being called break out of jquery ajax call.

can please me break out of ajax call if there no data response.

an ajax call ends in success return data. if server has no data return, return empty object of datatype (in case json). you'll have check if json object contains data.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -