ajax onexception,#14683 (ajax: Exceptions thrown synchronously by xhr.send are not caught) – jQ...

本文探讨了在jQuery 2.0.2及以上版本中,尝试获取无效URL时出现的NetworkError问题,指出与jQuery 1.10.2版本的不同,并提供了代码示例和复现情况。焦点在于版本间的兼容性和预期行为的改变。
摘要由CSDN通过智能技术生成

When an invalid url is passed to $.get, Chrome throws an NetworkError and no callbacks are called.

Expected result: Both fail() and always() should get called.

Code sample:

$.get('//example.com:80q').then(function () {

console.log('not called');

}).fail(function () {

console.log('not called');

}).always(function () {

console.log('not called');

});

Full error message:

XMLHttpRequest cannot load http://example.com:80q/. Cross origin requests are only supported for HTTP. jquery-2.0.2.js:7858

Uncaught NetworkError: A network error occurred. jquery-2.0.2.js:7321

Tested versions: 2.0.2, 2.0.3

Reproduced in: Chrome 31.0.1650.63

Couldn't reproduce in: IE10, Firefox 26

This does work as expected using jQuery 1.10.2, which makes me think it's an regression. ​http://jsfiddle.net/4FxSt/1/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值