我的代码如下:
function ajaxSyncCall(urlStr) {
var obj;
if (window.ActiveXObject) {
obj = new ActiveXObject('Microsoft.XMLHTTP');
} else if (window.XMLHttpRequest) {
obj = new XMLHttpRequest();
}
obj.open('POST', urlStr, false);
obj.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
alert(obj.responseText);
var result = Ext.util.JSON.decode(obj.responseText);
return result;
}通过传入的urlStr它的json格式为:如下:{"root":[{"header":"測驗1","dataIndex":"chikgiam","width":50},{"header":"平時分","dataIndex":"AVERAGE","width":50},{"header":"考試分","dataIndex":"EXAM","width":50},{"header":"總分","dataIndex":"TOTAL","width":50}],"success":true}在alert部分出现空不是null,运行到
var result = Ext.util.JSON.decode(obj.responseText);后直接出错火狐直接提示错误:
syntax error
[Break On This Error] ()这是为什么?

解决方案 »

  1.   

    问题解决了,先下载ext-basex补丁包。然后在页面添加引用<script src="<c:url value="/extjs/ext-basex.js" />"></script>在js页面使用
    var results;
    Ext.Ajax.request({
    method : 'POST',
    url : "/erips/portfolio/srcs/getScoreSheetHeaders.htm",
    async : false,
    success : function(response) {
    results = Ext.util.JSON.decode(response.responseText).root;
    }
    });即可