I am having trouble getting the VBscript on a .asp page to assign values to variables which are sent by the jQuery ajax() function.
I have this code on several other sites and it works fine, but for some reason it won't work on this website.
Just in case it makes a difference we are running the sites through IIS7.
The issue is that the variables on the VBscript page don't get assigned any of the values passed in the javascript page. However if I change the POST to GET and change request.form to request.queryString it does work. The problem with GET is that we can't enter very much data into the Description field of our form without getting a 414 error - Hence the use of POST.
As I said, I have this code on several other sites so I can't figure out why it isn't working here.
Here is my code (It is a mix of older code and newer code):
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
Any help is appreciated.