Jquery UI自动完成 - 如何将变量从Jquery传递给ashx处理程序

时间:2013-03-13 09:54:33

标签: jquery-ui-autocomplete generic-handler

我正在使用Jquery UI多值自动完成,我正在向服务器发出请求:

.autocomplete({
          source: function(request, response) {
              $.getJSON("handlers/autocomplete.ashx", {
                  term: extractLast(request.term)
              }, response);
          },

如何在我的.ashx处理程序中取回term的值?

我已尝试过Request.Form["TextBox1"],但我收到object reference not set to an intance of an object错误。有什么方法可以直接得到它吗?

谢谢

1 个答案:

答案 0 :(得分:2)

使用url传递TextBox1值

.autocomplete({
          source: function(request, response) {
              $.getJSON("handlers/autocomplete.ashx?TextBox1=curtxt", {
                  term: extractLast(request.term)
              }, response);
          },

从Handlers中读取TextBox1  public void ProcessRequest(HttpContext context)         {

        HttpRequest request = context.Request;
        HttpResponse response = context.Response;

string txtval = request["TextBox1"];

   }