Thursday, 15 September 2011

ajax - how to handle 404 error in jquery.post -



ajax - how to handle 404 error in jquery.post -

i not know how handle 404 error on $.post()??

$.post(url, data, function(returneddata) {

it can handle success info want handle 404 error in.i know how ajax dont know function please help.

function returndata(url,data,type){ $.post(url, data, function(returneddata) { if(type == "contacts") { ko.applybindings(new contactsviewmodel(returneddata,"#knockoutcontacts",url,data),$("#knockoutcontacts")[0]); ko.applybindings(new contactsviewmodel(returneddata,"#contactdetails",url,data),$("#contactdetails")[0]); } else if(type == "logs") { alert(returneddata); alert(1); ko.applybindings(new logsviewmodel(returneddata,url,data),$("#knockoutlogs")[0]); } else if(type == "sms") { ko.applybindings(new smsviewmodel(returneddata,"#knockoutsmsdata",url,data),$("#knockoutsmsdata")[0]); ko.applybindings(new smsviewmodel(returneddata,"#knockoutsms",url,data),$("#knockoutsms")[0]); } else if(type == "calendar") { ko.applybindings(new calendarviewmodel(returneddata,"#knockoutcalendar",url,data),$("#knockoutcalendar")[0]); } else if(type == "search") { ko.applybindings(new searchviewmodel(returneddata,"#searchbox",url,data),$("#searchbox")[0]); } else if(type == "location") { ko.applybindings(new locationviewmodel(returneddata,"#knockoutmaps",url,data),$("#knockoutmaps")[0]); } else if(type == "photos") { ko.applybindings(new photosviewmodel(returneddata,"#photogallary",url,data),$("#photogallary")[0]); ko.applybindings(new photosviewmodel(returneddata,"#photosdown",url,data),$("#photosdown")[0]); } }); }

i bascially apply bindings when info when dont info doesnt go within success function , thats breaking js.

you can utilize global error handler:

$(document).ajaxerror(function(e, xhr, settings, exception) { });

jquery ajax post .post

No comments:

Post a Comment