首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

extjs 使用 Poxy 请求webService header Content-Type设置有关问题,分不够

2013-06-25 
extjs 使用 Poxy 请求webServiceheader Content-Type设置问题,分不够 qa.data.GEN_QA_PART new Ext.data

extjs 使用 Poxy 请求webService header Content-Type设置问题,分不够
 




qa.data.GEN_QA_PART = new Ext.data.JsonStore({
    model: "GEN_QA_PART",
    loadingText: false,
    autoDestory: true,
    autoLoad: false,
    proxy: {
        type: 'ajax',
    //    jsonData: Ext.util.Format.format('{userId: "{0}"}', 'aadd'),
        headers: { "Accept": 'application/json', "Content-Type": 'application/json' },
        url: 'GQSService.asmx/GetPartList',
        reader: {
            type: 'json',
            root: 'd',
            idProperty: 'PART_ID'
        }
    },
    listeners: {
        scope: this,
        load: function () {
        }
    }
});


WebService文件:


  [ScriptMethod(ResponseFormat = ResponseFormat.Json), WebMethod(EnableSession = true)]
    public List<GEN_QA_PART> GetPartList()
    {
        string errMsg = string.Empty;
        List<GEN_QA_PART> lst = GEN_QA_PARTBLL.GePartList(string.Empty, ref errMsg);
        if (!string.IsNullOrEmpty(errMsg))
        {

        }


        return lst;
    }

报错信息:
Message":"尝试使用 GET 请求调用方法“GetPartList”,但不允许这样做。","StackTrace":"


当我将   headers: { "Accept": 'application/json', "Content-Type": 'application/json' },改成:  headers: { "Accept": 'application/json', "Content-Type": 'charset-utf-8'},
时返回是一个XML对象的数据格式。并不是我想要的JSON数据格式。

求解!!分不够,请谅解! 




[解决办法]
 

  Ext.Ajax.request({
        method: 'POST',
        headers: { "Accept": 'application/json', "Content-Type": 'application/json' },
        url: 'GQSService.asmx/GetDefect_GroupList',
});



如果采用这种方式调用又没有问题。。真搞不明白。为什么使用Proxy就报错。

热点排行