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

JQuery如何引用本页的request参数? - Web 开发 / Ajax
$.ajax({
  async: true, 
  cache: true,
  type: "POST",
  dataType: "xml",
  url: "processHandler.ashx?kind=direct&code=1",
  data: {key:"value"},
  error: function(xml) {alert('Error loading XML document11:' + xml);},
  timeout: 1000,
  success: function(xml) { 
  // 处理代码.....
  });
  }
  });

在上面的url: "processHandler.ashx?kind=direct&code=1"想改成url: "processHandler.ashx?kind=direct&code="+request("code"),
可是始终取不到request的参数值,不知该如何引用本页的request参数?


------解决方案--------------------
把request("code")换成<%=request.getParameter("code")%>试试!
------解决方案--------------------
JScript code

var queryString=function(key){
    return (document.location.search.match(new RegExp("(?:^\\?|&)"+key+"=(.*?)(?=&|$)"))||['',null])[1];
}
var c=queryString("code")

------解决方案--------------------
学习阶段jquery
------解决方案--------------------
JScript code
$.ajax({ 
                async: true, 
                cache: true, 
                type: "POST", 
                dataType: "xml", 
                url: "processHandler.ashx"+location.search, //========
                data: {key:"value"}, 
                error: function(xml) {alert('Error loading XML document11:' + xml);}, 
                timeout: 1000, 
                success: function(xml) { 
                    // 处理代码..... 
                            }); 
                    } 
        });

------解决方案--------------------
把request("code")换成 <%=request.getParameter("code")%>这样应该是可以的。