javascript - Triggering an 'error' type eventlistener on a HTTPRequest? -


i have httprequest use send below:

  cw.xhr.load({   "method": "get",   "rdata": datajson,   "url": "php/entries.php",   "responce": {     "load": formatresults,     "error": errorloading   } 

-- cw.xhr xhr request use send above object. in httprequest, have added eventlistner on "load" , "error"

this works fine , if echo entries.php, trigger 'formatresults' js function , can capture response text request.

what want know however, how trigger error eventlistener type? if don't want echo back, say, search results, alert there no results, want trigger 'errorloading' function.

(no jquery please) guys!

return either status code other 200 (such 400) or object represents error server, call error handler function.

function formatresults(response){     if(response.error){        this.errorloading({error: response.error});        return;    }     if(response.status != 200){        this.errorloading({status: response.status});        return;    }     //else no error , continue executing code below line  } 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

objective c - Ownership modifiers with manual reference counting -

python 3.x - Mapping specific letters onto a list of words -