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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -