Prevent Unhandled jQuery AJAX Error -


i know how receive server data or error. there many ways. example:

$.ajax({     type: "get",     url: "/widgets/",     success: function (data, text) {         console.log('this data');     },     error: function (request, status, error) {         console.log('this error');     } }); 

please see image:

result in chrome developer console

i have error function , need there. how can prevent error in first line. have tested 4xx , 5xx errors no difference. know end user not see error when developer console hidden.

i need design api. know can send 200 responses server additional argument show error or success result.

but if can send 4xx or 5xx responses there no need argument. way has additional gains me. example can apply success result client side models without worry additional args.

thank you

afaik cannot make red thingies go away, when returning error status-codes (4xx, 5xx). used browser indicate might have not gone expected. still these mere decorations, since 4xx , 5xx status codes valid, don't see reason wanting eliminate them.

as said yourself, other alternative sending "200 responses server additional argument show error or success result".

i recommend using 4xx , 5xx codes though (that's designed for) , stop worrying browser's heads-up warnings in developer console (aka red thingies).

see this , this questions refer similar errors when fetching other kinds of resources (images, files etc). errors see of same nature.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -