Ajax 未将数据发布到经典 asp 页面
Ajax not posting to data to classic asp page
我正在处理两个经典 asp 页面。在第一页中,我有一个带有按钮的模态对话框,单击该按钮会将数据发送到第二个 asp 页面。
问题是当 运行 时我收到了一个 "success" 回调,但数据没有发布到第二页。
这是第一页:
<script>
$(function() {
$("#SendNegAdj").click(function() {
$("#dialog").dialog({
title:"Send Negative Adjustment",
width: 400,
height: 200,
modal: true,
buttons: {
Send:
function(){
$.post("http://test.asp",
{libid:"test"});
console.log(libid);
//$(this).dialog('close');
},
Close:
function(){
$(this).dialog('close');
}
}
});
});
})
这里是数据应该发布到的地方:
<% Dim test
test = Request("libid")
Response.Write test
%>
您的代码首先使用 $.post()
通过 Ajax 发出 POST 请求。如果它获得成功的响应,它会忽略该响应中的数据并运行 location.replace
以向相同的 URL.[=12 发出 全新的 GET 请求=]
然后浏览器显示对 GET 响应的响应。
如果您想发出 POST 请求并将结果显示为新页面,请提交表单。不要使用 Ajax.
您需要使用Request.Form()
:
<% Dim test
test = Request.Form("libid")
Response.Write test
%>
我正在处理两个经典 asp 页面。在第一页中,我有一个带有按钮的模态对话框,单击该按钮会将数据发送到第二个 asp 页面。
问题是当 运行 时我收到了一个 "success" 回调,但数据没有发布到第二页。
这是第一页:
<script>
$(function() {
$("#SendNegAdj").click(function() {
$("#dialog").dialog({
title:"Send Negative Adjustment",
width: 400,
height: 200,
modal: true,
buttons: {
Send:
function(){
$.post("http://test.asp",
{libid:"test"});
console.log(libid);
//$(this).dialog('close');
},
Close:
function(){
$(this).dialog('close');
}
}
});
});
})
这里是数据应该发布到的地方:
<% Dim test
test = Request("libid")
Response.Write test
%>
您的代码首先使用 $.post()
通过 Ajax 发出 POST 请求。如果它获得成功的响应,它会忽略该响应中的数据并运行 location.replace
以向相同的 URL.[=12 发出 全新的 GET 请求=]
然后浏览器显示对 GET 响应的响应。
如果您想发出 POST 请求并将结果显示为新页面,请提交表单。不要使用 Ajax.
您需要使用Request.Form()
:
<% Dim test
test = Request.Form("libid")
Response.Write test
%>