【发布时间】:2014-01-15 00:47:46
【问题描述】:
我正在向 localhost 发送 jsonp 请求以获取 json 数据。但我收到请求超时。我无法找出超时的原因。 有谁能够帮我?下面是函数
init: function() {
var me = this;
//making the jsonp request to fetch data
console.log("init start");
Ext.data.JsonP.request({
url : 'http://localhost/TwitterApp/resources/json/Data.json',
success: function(response){
//populating the data in the store
//console.log("aaaa" + response);
var store = me.getDataStore();
store.loadData(response);
//console.log("on Init" + store);
me.getStatistics().renderColumnCharts(store);
},
failure: function(response){
console.log(response);
}
});
},
这是 Data.json 文件。它与代码中指定的位置相同
[
{
Hashtag: "Hello",
Value: 1
},
{
Hashtag: "Hi",
Value: 4
},
{
Hashtag: "Obama",
Value: 61
},
{
Hashtag: "Close",
Value: 551
},
{
Hashtag: "MOD",
Value: 15
},
{
Hashtag: "winter",
Value: 51
},
{
Hashtag: "chadar",
Value: 71
},
{
Hashtag: "bottle",
Value: 17
},
{
Hashtag: "jaiHo",
Value: 154
},
{
Hashtag: "Madhur",
Value: 144
},
{
Hashtag: "Plank",
Value: 142
},
{
Hashtag: "Gft",
Value: 1
}
]
我尝试检查网络请求。在响应正文中以文件形式显示 json 内容。但它仍然会失败并给出超时。 特此附上截图
【问题讨论】:
-
您确定
http://localhost/TwitterApp/resources/json/Data.json存在吗?我们能看到它的输出吗? -
@A1rPun 是的。这个文件确实存在。上面结账。我得到的输出是,它在我输出响应的故障函数中。我在控制台上得到“超时”作为输出。
-
超时发生在 30 秒左右吗?如果是这样,可能与jsonp超时限制有关。我尝试在sencha fiddle 中模拟代码,但没有收到相同的错误。
-
@weeksdev 我尝试增加超时时间,但我仍然只收到超时错误。
标签: javascript extjs jsonp