读书人

ajax在后台如何获取data值

发布时间: 2012-10-13 11:38:17 作者: rapoo

ajax在后台怎么获取data值?

JScript code
options = {                    type: "POST",                    url: ajaxPage,                    data:{"Formula":escape(textarea),"FieldNames":escape(fieldNames)},                    contentType: "application/json;charset=utf-8",                    dataType: "string",                    async: false                };                returnText = $.ajax(options).responseText;

后台onLoad事件
C# code
if (Request["mn"] != null && Request["mn"] == "Detection")                {                    Response.ContentType = "application/json";                    Response.Write(IsExist());                    Response.End();                }


在if里面怎么获取data的值?

[解决办法]
取消escape,jq已经自动用encodeURIComponent编码过一次了

JScript code
options = {                    type: "POST",                    url: ajaxPage,                    data:{"Formula":textarea,"FieldNames":fieldNames},///////////                   // contentType: "application/json;charset=utf-8",//不要设置contentType为这个,要不服务器端生成不了键值对                    //dataType: "string",//dataType没有string类型,不过设置为这个也行,会自动变为text                    dataType: "text",                    async: false                }; 

读书人网 >Ajax

热点推荐