我将strng数组值传递给handler。但是我无法在HttpHandler ProcessRequest中读取这些值。我怎样才能获得这些价值。?
客户端代码:
var advSearchTypes=["abc","def","ghi","jkl"]; $.ajax({ url: 'SearchHandler.ashx', type: 'post', data: ({"SearchKey": searchKey,"AdvSearchTypes": advSearchTypes}),
success: function (response) { }, error:function(){ } });
处理程序代码:
public void ProcessRequest(HttpContext context) {
string aSearchKey = context.Request.Form["SearchKey"].ToString();
string[] aSearchTypes = context.Request.QueryString["AdvSearchTypes"].Split(','); }
context.Request.QueryString["AdvSearchTypes"]
显示为空。
如何获取字符串数组值??
答案 0 :(得分:1)
你可以在这里改变
从type=post
到get
var advSearchTypes=["abc","def","ghi","jkl"]; $.ajax({ url: 'SearchHandler.ashx', type: 'get', data: ({"SearchKey": searchKey,"AdvSearchTypes": advSearchTypes}),
success: function (response) { }, error:function(){ } });
或处理程序代码
public void ProcessRequest(HttpContext context) {
string aSearchKey = context.Request.Form["SearchKey"].ToString();
string[] aSearchTypes = context.Request.Form["AdvSearchTypes"].Split(','); }