第一个问题:
当用户删除特定行时,我必须删除该行仅用于页面刷新。 使用ajax删除行。我该怎么做
第二个问题: 实际上我正在计算从那天到前7天的页面点击次数。 但我想今天页面点击时我必须检索前一周 意味着从周日(2011年11月20日)到周六(2011年11月20日) 当页面在下一个星期一点击,所以我必须检索本周的记录 从周日(2011年11月27日)到周六(2011年12月3日)的手段
function authenticate(){
$.ajax({
type: "POST",
url: "authentication.php",
data: $("#login_form").serialize(),
success: function(msg){
if(msg==1){
$('#delete').html("success"); //if success message appear only i have to remove particular row
})
}else{
$('#delete').html("error");
}
},
error:function(msg){
alert(msg);
$('#delete').dialog("close");
}
});
}
<div style='display: none;' id='delete'></div>
<table border="1">
<tr>
<th>Title</th>
<th>Public Id</th>
<th>Pass</th>
<th></th>
</tr>
<?php
$select = $db->select ()
->from ( 'test', '*' )
->where ( 'user_id = ?', 1 )
->where ( 'test.created > DATE_SUB(CURDATE(), INTERVAL 7 DAY)' );
$tourDetails = $db->fetchAll ( $select );
$i = 0;
foreach ( $tourDetails as $row1 ) {
$i ++;
$title = $row1 ['title'];
$PublicId = $row1 ['public_id'];
if (($i % 2) == 0 ) {
$rowResponse = prepareRow ( true, $title, $PublicId);
echo $rowResponse;
} else {
$rowResponse = prepareRow ( false, $title, $PublicId);
echo $rowResponse;
}
}
function prepareRow($flag, $title, $PublicId) {
$rowResponse = "";
if ($flag) {
$rowResponse .= '<tr class="even">';
} else {
$rowResponse .= '<tr class="odd" >';
}
$rowResponse .= '
<td> ' . $title . ' </td>
<td> ' . $publicId . ' </td>
<td><p><a onclick=openDialog("'. $PublicId .'","delete") href="#" id="dialog_link">
Delete </a></p>
</td>';
return $rowResponse;
?>
</table>
答案 0 :(得分:3)
您可以使用jQuery的nth-child选择器。
$("table#mytableid tr:nth-child(2)").remove();
这将删除第二行,例如。确保您的表具有ID或类,以便您更容易地选择它(不要意外地删除页面上的每一个表的第二行,以防您有更多)...
修改
从我在你的代码中看到的,你可以从onclick事件中选择父tr元素,然后将它作为一个新参数发送给函数(你将删除它,ajax返回成功)或立即删除它......或者你想要的任何东西。
答案 1 :(得分:0)
$('#myTableRow').remove();
This works fine if your row has an id, such as:
<tr id="myTableRow"><td>blah</td></tr>
答案 2 :(得分:0)
使用IEnumerable<Task>
例如:
WhenAll()