Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jqueryajax和VBscript-Can';在jQueryAjax中使用POST时,无法在VBscript变量中获取值_Jquery_Ajax_Post_Vbscript_Get - Fatal编程技术网

jqueryajax和VBscript-Can';在jQueryAjax中使用POST时,无法在VBscript变量中获取值

jqueryajax和VBscript-Can';在jQueryAjax中使用POST时,无法在VBscript变量中获取值,jquery,ajax,post,vbscript,get,Jquery,Ajax,Post,Vbscript,Get,我无法让.asp页面上的VBscript为jQuery ajax()函数发送的变量赋值 我在其他几个网站上都有这段代码,它运行得很好,但由于某些原因,它在这个网站上不起作用 为了以防万一,我们正在通过IIS7运行这些站点 问题是VBscript页面上的变量没有被分配javascript页面中传递的任何值。 但是,如果我将POST更改为GET,并将request.form更改为request.queryString,它确实可以工作。 GET的问题是,我们无法在表单的描述字段中输入大量数据,而不会出

我无法让.asp页面上的VBscript为jQuery ajax()函数发送的变量赋值

我在其他几个网站上都有这段代码,它运行得很好,但由于某些原因,它在这个网站上不起作用

为了以防万一,我们正在通过IIS7运行这些站点

问题是VBscript页面上的变量没有被分配javascript页面中传递的任何值。 但是,如果我将POST更改为GET,并将request.form更改为request.queryString,它确实可以工作。 GET的问题是,我们无法在表单的描述字段中输入大量数据,而不会出现414错误,因此使用POST

正如我所说,我在其他几个网站上都有这段代码,所以我不明白为什么它在这里不起作用

这是我的代码(它是旧代码和新代码的混合):

javascript:

var prodID = document.forms['hidden'].prodid.value;
var strSubCatID = document.forms['frmProducts'].cmbSubCategory.value;
var strName = encodeURIComponent(document.forms['frmProducts'].txtName.value);
var strDescription = encodeURIComponent(document.forms['frmProducts'].txtDesc.value);

jQuery.ajax({
    type: "POST",
    url: "/_ajax/products/updateDescription.asp",
    data: {
        "prodid": prodID,
        "strName": strName,
        "strSubCatID": strSubCatID,
        "strDescription": strDescription
    },
    success: function () {
        alert("Update successful")
    },
    error: function (xhr) {
        alert("Error occured during Ajax request, the error status is: " + xhr.status);
    }
});    
VBscript:

dim strSubCatID : strSubCatID = request.form("strSubCatID")
dim strName : strName = request.form("strSubCatID")
dim strDescription : strDescription = request.form("strDescription")
dim strProdID : strProdID = request.form("strProdID")

strSQL = "UPDATE tblProducts SET "
strSQL = strSQL & "SubCatID = '" & strSubCatID & "', "
strSQL = strSQL & "Name = '" & strName & "', "
strSQL = strSQL & "Description = '" & strDescription & "' "
strSQL = strSQL & " WHERE ProdID = '" & strProdID & "'"

dim rs : set rs=Server.CreateObject("ADODB.recordset")
rs.Open strSQL, cn, 3, 3

非常感谢您的帮助。

问题在于您的变量不匹配,例如,您正在发布
prodid
,但正在查找
strProdID
,而且在将数据作为对象传递之前不需要编码,让jQuery在内部进行编码,例如:

jQuery.ajax({
  type: "POST",
  url: "/_ajax/products/updateDescription.asp",
  data: {
    strProdID:      $("form[name=hidden] [name=prodid]").val(),
    strName:        $("form[name=frmProducts] [name=txtName]").val(),
    strSubCatID:    $("form[name=frmProducts] [name=cmbSubCategory]").val(),
    strDescription: $("form[name=frmProducts] [name=txtDesc]").val()
  },
  success: function() {
    alert("Update successful")
  },
  error: function(xhr){
    alert("Error occured during Ajax request, the error status is: " + xhr.status);
  }
});
在VBScript端,您还有:

strName = request.form("strSubCatID")
看起来应该是:

strName = request.form("strName")