I am trying to request an XML from a .NET service which I need to enter in DB through a Classic ASP code. I am using two AJAX requests to do same.
Through 1st I am calling the .NET code and receiving the XML. In second AJAX I am sending back the XML to an ASP page which enters the same in DB.
here is AJAX Code
$(document).ready(function () {
$.ajax({
crossDomain: true,
type: "GET",
cache: false,
contentType: "xml/text; charset=utf-8",
async: false,
url: --..Some .NET url...--,
dataType: "text",
success: function (result, status, xhr) {
//var xml_serializer = new XMLSerializer();
//var abc = xml_serializer.serializeToString(result);
var xml = encodeXml(result);
alert(xml);
$.ajax({
type: "POST",
data : { xmlsent: xml },
url: --ASP URL--,
contentType: "text/xml; charset=utf-8",
dataType: "text",
success: function (result1, response , xhr) {
debugger;
alert(xml);
alert(result1);
},
failure: function (response) {
debugger;
alert(response);
}
});
},
error: function (xhr, status, error) {
alert("eRROR");
alert(error);
}
});
});
My Classic ASP Code
Dim cnn, sql
Dim UserID
Set cnn = Server.CreateObject("ADODB.connection")
cnn.Open cConnectionString 'Connection string is set already
UserID= Request.Form("xmlsent") & "abc5"
sql=""
sql = sql & " UPDATE tablename set columnname='" & UserID & "' Where colid = 123"
cnn.Execute(sql)
Response.Write UserID
Now update in Db works' that means my ASP code is being called but the value which is being set in DB is just "abc5" that means that Request.Form("xmlsent") is null (this is the main issue)
Also 1st alert with XMl works fine and I am able to see XML in an alert box. Even second XMl worksi.e
. my ASP page is also called. Db update is done but with null append with "abc5"
Note: the Ajax code is in the different page as from ASP code.