With the following jQuery.ajax response…
{"ysearchresponse":
{"responsecode":"200","totalhits":"0","deephits":"0","count":"0","start":"0"}}
How do I do a comparison on “totalhits” in order to execute the error: function() when totalhits == “0” ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t.(see first comment). And trust me, you don’t want to. The error callback is meant for errors related to the ajax request and not for errors only you consider errors (i.e. nonsense data which is valid json/xml/whatever or an empty resultset).However, if you want your error function called, create it as a regular (named) function instead of an anonymous one and call it manually when your criteria are met. Note that making your function a regular one results in it not being a closure anymore – but without seeing your full
$.ajax(...);call and some surrounding code it’s impossible to tell if that’ll be a problem or not.