sar*_*ake 9 jquery post redirect
我对Jquery相对较新,我想知道如何将变量发布到另一个页面然后重定向?我使用了ajax函数,重定向工作正常,但在POST中没有捕获变量(它们是空的)
function linkWO() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "LinkTagOut.aspx",
dataType: "json",
data: "{id=1}",
complete:
function () {
window.location = "LinkTagOut.aspx";
}
});
}
Run Code Online (Sandbox Code Playgroud)
在我的aspx文件中
<a href="javascript:void(0);" onclick="return linkWO();"><span>Link</span></a>
Run Code Online (Sandbox Code Playgroud)
这个答案只是为了快速修复
为什么不在这里作为查询字符串传递
window.location = "LinkTagOut.aspx?variabletopass=test";
Run Code Online (Sandbox Code Playgroud)
<form id="target" action="destination.html">
<input type="text" value="Hello there" />
<input type="submit" value="Go" />
</form>
<div id="other">
Trigger the handler
</div>
$('#target').submit(function() {
$.post('ajax/test.html', function(data) {
});
return false;
});
Run Code Online (Sandbox Code Playgroud)