Error handling in getJSON calls

后端 未结 9 1664
野的像风
野的像风 2020-11-28 02:09

How can you handle errors in a getJSON call? Im trying to reference a cross-domain script service using jsonp, how do you register an error method?

9条回答
  •  感动是毒
    2020-11-28 02:26

    $.getJSON("example.json", function() {
      alert("success");
    })
    .success(function() { alert("second success"); })
    .error(function() { alert("error"); })

    It is fixed in jQuery 2.x; In jQuery 1.x you will never get an error callback

提交回复
热议问题