【问题标题】:ajax post getting value in CLASSIC aspajax post 在 CLASSIC asp 中获得价值
【发布时间】:2023-12-26 11:41:01
【问题描述】:

我正在尝试使用 jquery AJAX 获取已发布文本框的值:

这是我的代码:

$(document).ready(function(){
$('#submitButton').click(function() {
    $.ajax({
            type: "POST",
            url: "test.asp",
            data:  $("#form1").serialize(),
            cache: false,
            dataType: "html",
            success: function(responseText){
                alert(responseText);
            },
            error: function(resposeText){
                alert(resposeText);
            },
        });

    return false;
});
 });

这是 test.asp 页面:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
dim vwPW

  vwPW = request.QueryString("vwPW")

  response.write "returned " & vwPW
%>

我的表格是:

<form id="form1" method="post" action="">
          <table width="100" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><input name="vwPW" id="vwPW" type="password" class="textBox" maxlength="10"  /></td>
                <td><button class="GreyB" id="submitButton" name="submitButton"><span style="color:#000">Log in</span></button></td>
              </tr>
            </table>
</form>

我得到的只是“重新调整”,之后什么都没有。我会做错什么?

大卫

【问题讨论】:

    标签: ajax jquery post asp-classic


    【解决方案1】:

    您的 ajax 正在使用 POST,ASP 需要使用 request.form 而不是 request.querystring 获取值 - 或者,将您的 ajax 更改为 GET

    【讨论】:

    • 谢谢,我知道这是小事。
    【解决方案2】:

    您的表单正在发布,因此您无法访问通过Request.QueryString 发送的变量,而是通过Request.Form。或者,将您的 ajax 调用更改为 type:'get'

    【讨论】:

      最近更新 更多