本文介绍了Ajax的数据 - 未捕获的ReferenceError:日期不定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Ziptastic,但我收到此错误:
statezip = statezip();
警报(statezip);
功能statezip(){
VAR twostate;
$阿贾克斯({
网址:http://zip.elevenbasetwo.com/v2/US/10010
数据类型:JSON,
异步:假的,
数据: {},
成功:功能(数据){
twostate = date.state;
返回twostate;
}
});
}
为什么我得到这个错误?
解决方案
您有一个错字在
date.state
这应该是:
data.state
顺便说这是不建议使用
异步:假的
由于所有的JavaScript正在等待Ajax请求有响应。它会减慢你的应用程序,绝对不是用它一个很好的做法。
I am using Ziptastic, but I'm receiving this error:
statezip = statezip();
alert(statezip);
function statezip() {
var twostate;
$.ajax({
url: "http://zip.elevenbasetwo.com/v2/US/10010",
dataType: 'json',
async: false,
data: {},
success: function (data) {
twostate = date.state;
return twostate;
}
});
}
Why do I get this error?
解决方案
You have a typo at
date.state
It should be:
data.state
By the way it is not suggested to use
async: false
As all the JavaScript is waiting for the ajax request to have a response. It will slow down your application and definitely is not a good practice to use it.
这篇关于Ajax的数据 - 未捕获的ReferenceError:日期不定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!