日期:2014-05-16  浏览次数:20630 次

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
                };