我目前有一个php文件正在执行:
<a href="test.php?foo=boo">test</a>我宁愿不必加载一个新页面并使用onClick。
有没有人知道一种简单的方法?
我添加了一个更完整的示例,包括建议的ajax。不过,我还是很难让它正常工作。
<script type="text/javascript">
$('li').click(function() {
$.ajax({ type: "GET", url: "test.php", data: { foo: 'boo' }, success: function(data){
// use this if you want to process the returned data
alert('complete, returned:' + data);
}});
});
</script>
</head>
<body>
<div id="header">
<h1>Title</h1>
</div>
<ul>
<li><a href="#">Test</a></li>
</ul>
</body>
</html>发布于 2010-11-24 17:03:53
是的,正如你的标签所说。您将需要使用AJAX。
例如:
$.ajax({
type: "GET",
url: "test.php",
data: "foo=boo"
});然后你只需要把它放在一个click函数中。
$('a').click(function() {
// The previous function here...
});EDIT:将方法更改为GET。
发布于 2010-11-24 17:04:40
您可以使用jquery并执行以下操作:
$.ajax({ url: "test.php", data: { foo: 'boo' }, success: function(data){
// use this if you want to process the returned data
// alert('complete, returned:' + data);
}});有关更多信息,请查看the jquery-documentation
发布于 2010-11-24 17:07:34
在你的第一句话中,例如try.html,写下这段代码
<meta http-equiv="refresh" content="2;url=test.php?foo=boo"> 它将在2秒内将u重定向到test.php?foo=boo
或其他方式的===========================================
创建一个php文件
<?php
header('Location: test.php?foo=boo');
exit;
?>希望这对你有所帮助
https://stackoverflow.com/questions/4264959
复制相似问题