Javascript JSON解析问题jquery,ajax
我用Javascript、Jquery和ajax编写的测试程序有点问题 这是我的代码: HTML 但是如果我检查网络,我看到我收到了请求,但是 我没有获得成功的消息,因此控制台不会记录任何内容。 这怎么可能呢?用Javascript JSON解析问题jquery,ajax,javascript,jquery,json,ajax,Javascript,Jquery,Json,Ajax,我用Javascript、Jquery和ajax编写的测试程序有点问题 这是我的代码: HTML 但是如果我检查网络,我看到我收到了请求,但是 我没有获得成功的消息,因此控制台不会记录任何内容。 这怎么可能呢?用.done()代替成功 function callPage(){ $.ajax({ url: "http://events.restdesc.org/", type: "GET", dataType:'json',
.done()
代替成功
function callPage(){
$.ajax({
url: "http://events.restdesc.org/",
type: "GET",
dataType:'json',
error: function(error){
console.log("the page was not loaded", error);
},
}).done(function(response) {
var data = response;
console.log("hey");
console.log(data.title);
});
}
“成功”中的输入错误?哦,不,我已经找了好几个小时了,这并没有显示任何错误webstorm@fangio“success”中的输入错误即使没有记录也会产生错误。@TyQ。它没有在我的浏览器中显示任何内容,也没有在我的编辑器中显示任何内容,我不知道这是一个拼写错误,没有显示任何内容,没有错误,没有日志,这个错误让我发疯了…@fangio“success”的拼写错误不是webstorm可以检测到的错误。但是“success”(缺少一个“s”)不是一个属性
$。ajax
正在寻找它。在这种情况下,它基本上被忽略了。对于捕捉方法名称中的拼写错误,这实际上是一种更好的方法。
$(document).ready(function(){
$('button').on('click',function(e){
callPage()
})
});
function callPage(){
$.ajax({
url: "http://events.restdesc.org/",
type: "GET",
dataType:'json',
succes: function (response) {
var data = response;
console.log("hey");
console.log(data.title);
},
error: function(error){
console.log("the page was not loaded", error);
},
});
}
function callPage(){
$.ajax({
url: "http://events.restdesc.org/",
type: "GET",
dataType:'json',
error: function(error){
console.log("the page was not loaded", error);
},
}).done(function(response) {
var data = response;
console.log("hey");
console.log(data.title);
});
}