我正打算致电Petfinder.com获取我们的宠物清单.网址是http://api.petfinder.com/shelter.getPets?key=xxxxx&id=CA1469&format=json
该网址似乎返回JSON罚款.但是,当我尝试拨打电话我得到"错误"和状态代码0我尝试使用JSONP导致200状态,但出现的语法错误.如果我改为xml,我得到状态0和"错误"的结果.
$.ajax({
url: "http://api.petfinder.com/shelter.getPets?key=xxxx&id=CA1469&format=json",
dataType: "json",
type: "GET",
success: function (data) {
alert("hi");
},
error: function (jqXHR, exception) {
if (jqXHR.status === 0) {
alert('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {
alert('Requested page not found. [404]');
} else if (jqXHR.status == 500) {
alert('Internal Server Error [500].');
} else if (exception === 'parsererror') {
alert('Requested JSON parse failed.');
} else if (exception === 'timeout') {
alert('Time out error.');
} else if (exception === 'abort') …Run Code Online (Sandbox Code Playgroud)