【发布时间】:2010-10-05 15:37:20
【问题描述】:
我无法让 .asp 页面上的 VBscript 为 jQuery ajax() 函数发送的变量赋值。
我在其他几个网站上都有这段代码,它运行良好,但由于某种原因,它无法在这个网站上运行。
以防万一我们通过 IIS7 运行网站。
问题是 VBscript 页面上的变量没有被分配任何在 javascript 页面中传递的值。 但是,如果我将 POST 更改为 GET 并将 request.form 更改为 request.queryString 它确实有效。 GET 的问题是我们不能在表单的 Description 字段中输入大量数据而不会出现 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);
}
});
VB脚本:
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
感谢任何帮助。
【问题讨论】:
标签: jquery ajax post vbscript get