我真的被困住了,想知道是否有人能帮忙,
我知道如何获得查询字符串,这不是问题,
但是,我有使用jquery淡出内容并通过链接加载新内容的链接,
下面的用法示例- class="link2“是jquery执行lol操作的参考。
点击这里
在href中,如果你明白我的意思的话,我必须先让#阻止页面加载,
现在,当我尝试获取查询字符串id=2时,它说没有--因为首先有一个#,可能有一个简单的修复方法,但是我一定是错过了它,我已经搜索了,但是仍然找不到答案
,这就是我想做的,
进入页面,sql查询运行以显示所有报表,单击报表,jquery隐藏"contmain“,并显示"contreports”,现在一个新的sql查询运行来显示基于"id“的报表。
现在,我通常只需从url获取这些信息并清理它,因为我已经运行了jquery,所以我需要href的"#“,这样页面就不会重新加载,jquery就可以运行了,但是现在我无法检索url查询,
Interstellar_Coder,他似乎有了正确的想法,在后台传递了它
发布于 2011-12-15 21:37:53
虽然我不完全理解您在做什么,但我想最好将查询字符串存储为data属性。
<a href="#" data-id="2" class="link2">click here</a> 然后在您的jQuery函数中。
$('.link2').click(function(e){
var queryString = $(this).data('id');
e.preventDefault(); // prevent the default action
}); 发布于 2011-12-16 18:31:17
因为这段代码我觉得最好在这里贴我想我已经接近了,
@Interstellar_Coder -这是我到目前为止所拥有的,但它只检索过第一个id,
$query1 = mysql_query("SELECT * FROM `".TBL_CATCH_REPORTS."` order by id DESC");
$query2 = mysql_num_rows($query1);
if(mysql_num_rows($query1) != 0) {?>
<table width="880" style="margin:0 auto">
<?PHP while ($output = mysql_fetch_assoc($query1)) { ?>
<tr class="row">
<td width="190px"><input type="button" class="c_report"value="<?PHP echo $output['id']; ?>" />
View Report <img src="images/icons/arrow_right.png" width="16" height="16" /></a></td>
<td width="210px">Submited by <?PHP echo $output['submitby']; ?></td>
<td width="160px"><?PHP echo $output['date']; ?></td>
<td><?PHP echo $output['title']; ?></td>
</tr>
<?PHP } ?>
</table>
<?PHP }else{ echo '.Sorry there are no catch reports yet'; }?>
<div id="contreport"> content here </div>
<script type="text/javascript">
$(document).ready(function(){
$(".c_report").click(function () {
$("#contreport").html('Getting Catch Report......');
$.ajax({
type: "POST",
data: "data=" + $(".c_report").val(),
url: "reportdata.php",
success: function(msg){
$("#contreport").html(msg)
}
});
});
});
</script>我的另一页"reportdata.php只获取值,然后在sql语句中使用。
$getreport = '';
if (isset($_POST['data']) and trim($_POST['data']) != '' ) {
$getreport = trim($_POST['data']);
} 我假设我需要在jquery中执行某种循环,但我只是迷路了,今天一整天都被困在这上面。
这就是我所需要的
id 1-链接
ID2-链接
ID3-链接
id 4-链接
id 5-链接
单击any,id将发送到sql语句中使用id的reportdata.php,然后返回并显示数据,它将真正地发送给我mad lol。
https://stackoverflow.com/questions/8526895
复制相似问题