gpt4 book ai didi

javascript - 如何在 HttpHandler ProcessRequest 中获取字符串数组值?

转载 作者:行者123 更新时间:2023-12-03 08:44:02 25 4
gpt4 key购买 nike

我正在将 strng 数组值传递给处理程序。但我无法读取 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"] 显示为 null。

如何获取字符串数组值。?

最佳答案

您可以在这里更改

type=postget

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(','); }

关于javascript - 如何在 HttpHandler ProcessRequest 中获取字符串数组值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32968672/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com