用POST将变量传递到使用Jquery的另一个页面 [英] Passing variables with POST to another page with Jquery
本文介绍了用POST将变量传递到使用Jquery的另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对Jquery还是比较陌生,我想知道一个变量如何发布到另一页然后重定向?我使用了ajax函数,重定向工作正常,但是POST中没有捕获任何变量(它们为空)
I am relatively new to Jquery and I was wondering how would one post variables to another page and then redirect? I used ajax function, the redirect works fine, but no variables are captured in POST (they are empty)
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";
}
});
}
在我的aspx文件中
<a href="javascript:void(0);" onclick="return linkWO();"><span>Link</span></a>
推荐答案
此答案只是为了快速解决
This answer is just for a quick fix
为什么不在此处作为查询字符串传递
why don't you just pass as query string here
window.location = "LinkTagOut.aspx?variabletopass=test";
<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;
});
这篇关于用POST将变量传递到使用Jquery的另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文