如何正确处理则httpStatus code

编程入门 行业动态 更新时间:2024-10-18 08:22:26
本文介绍了如何正确处理则httpStatus code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想C $ CS(如200,201或202)的新功能(api.jquery/jQuery.ajax)的HTTP状态 - $反应。但功能无视我的201和202的回调。

与Firefox,4.0_b10和铬9.0这个错误occures

我期待着解决这个小问题。

问候斯特凡

我的code-剪断:

jQuery.ajax({         网址:网址,         数据类型:JSON,         状态code:{           404:功能(){警报(404); },           200:函数(){警报(200); },           201:函数(){警报(201); },           202:功能(){警报(202); }         },         成功:功能(数据){           开关(data.status){             案做:               / *把它显示给用户* /               打破;           }         });

解决方案

解决方法如下:

jQuery.ajax({         网址:网址,         数据类型:JSON,         状态code:{           404:功能(){警报(404); },           200:函数(){警报(200); },           201:函数(){警报(201); },           202:功能(){警报(202); }         } / *,         成功:功能(数据){           开关(data.status){             案做:               / *把它显示给用户* /               打破;           }         } * /         });

不知怎么的,成功的,方法是在冲突的则httpStatus code-地图

问候斯特凡

I would like to react on http status-codes (like 200, 201 or 202) with the new feature (api.jquery/jQuery.ajax). But the function is ignoring my 201 and 202 callbacks.

This error occures with firefox-4.0_b10 and chromium-9.0

I'm looking forward to fix this little issue.

Regards Stefan

My code-snipped:

jQuery.ajax({ url: url, dataType: 'json', statusCode: { 404:function() { alert("404"); }, 200:function() { alert("200"); }, 201:function() { alert("201"); }, 202:function() { alert("202"); } }, success: function(data){ switch(data.status) { case 'done': /* display it to the User */ break; } });

解决方案

The solution is the following:

jQuery.ajax({ url: url, dataType: 'json', statusCode: { 404:function() { alert("404"); }, 200:function() { alert("200"); }, 201:function() { alert("201"); }, 202:function() { alert("202"); } }/*, success: function(data){ switch(data.status) { case 'done': /* display it to the User */ break; } }*/ });

Somehow, the success-method is in conflict with the httpStatusCode-Map

Regards Stefan

更多推荐

如何正确处理则httpStatus code

本文发布于:2023-11-24 04:40:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624008.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正确处理   httpStatus   code

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!