Ajax.request使用ExtJs [英] Ajax.request using ExtJs

查看:146
本文介绍了Ajax.request使用ExtJs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从文件加载JSON内容。 console.log 打印服务器端故障,状态码为0,表示请求失败。

I'm having difficulty loading JSON content from a file. console.log prints "server-side failure with status code 0", meaning that the request failed.

我的JSON文件网址是正确的,文件存在于给定的地址。

My JSON file URL is correct and the file is present at the given address.

Firebug显示错误:

Firebug shows the error:

"NetworkError: 405 Not Allowed - http://localhost:8080/4910.json?_dc=1336714070619

,Net标签显示状态 405不允许

and the Net tag shows status 405 not allowed.

任何想法为什么会发生这种情况?

Any ideas on why this is happening?

Ext.Ajax.request({
                   url: 'http://localhost:8080/4910.json',
                   success: function(response, opts) {
                      var obj = Ext.decode(response.responseText);
                      console.log(obj[0].name);
                   },
                   failure: function(response, opts) {
                      console.log('server-side failure with status code ' + response.status);
                   }
                });

另外,在GET请求的结尾添加参数 _dc = 1336714070619

Also, what is adding the parameter _dc=1336714070619 to the end of the GET request?

推荐答案

只是FYI ..

对于谁添加参数_dc 。 dc代表禁用缓存

默认情况下,extjs中的每个请求都将自动附加请求变量( _dc )。更多信息

For the Who is adding parameter _dc. dc stands for disable cache.
by default, every request in extjs will automatically append the request variable with _dc. more info

如果您不想要,只需将 disableCaching:false

If you don't want it, just set disableCaching: false to your request

Ext.Ajax.request({
    disableCaching: false,
    url: 'http://localhost:8080/4910.json',
    ......
});

对于为什么不允许

尝试打开没有 _dc 的JSON URL路径,或者您的服务器可能出现问题。

For the why not allowed.
Try opening the JSON URL path without _dc, or maybe there is something wrong with your server.

这篇关于Ajax.request使用ExtJs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆