我正在使用带有 IIS Express 的Visual Studio 2013。
我的html页面有一个JavaScript(EXTJS),它在 HTTP POST方法上调用 file.json 。 我得到" HTTP错误405.0 - 方法不允许"
我尝试在web.config中添加以下内容
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
在命令提示符下面的命令
appcmd set config /section:staticContent /+[fileExtension='JSON',mimeType='application/x-javascript']
没有任何帮助。
我可以使用GET请求访问.json文件,例如http://localhost/file.json
,但不能使用POST请求。
这是我的ExtJS代码,调用该JSON文件
Ext.onReady(function () {
var tree = new Ext.tree.TreePanel({
renderTo: 'tree-div',
title: 'My Task List',
height: 300,
width: 400,
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
rootVisible: false,
frame: true,
root: {
nodeType: 'async'
},
dataUrl: 'file.json'
});
tree.getRootNode().expand(true);
});
file.json具有以下结构化的JSON
[{
text: 'To Do',
cls: 'folder',
children: [{
text: 'Go jogging',
leaf: true,
checked: false
},{
text: 'Take a nap',
leaf: true,
checked: false
},{
text: 'Climb Everest',
leaf: true,
checked: false
}]
},.....
答案 0 :(得分:0)
将TreePanel配置中的requestMethod
设置为GET
,以强制它发出GET请求而不是POST。
var tree = new Ext.tree.TreePanel({
...
requestMethod: 'GET',
...
});