提交表格后重新加载div

时间:2010-05-28 04:55:11

标签: php jquery

我有这样的代码。这实际上是一种形式。它允许用户更新他的评级。一旦他点击更新或保存。我做了一个ajax并保存他的评级并给他成功的消息。但我怎么能刷新这个div以显示他的新评级,我需要在接下来的2分钟内阻止此用户的更新/保存。我会这样做吗?我使用jquery框架

$ myresult。='';

$myresult .= '<form name =\'form1\' id=\'form1\' method = \'POST\' action=\''.$_SERVER['php_self'] .'\'>';


/* actual rating table - start - actual rate/update */

$myresult .= '<table id=\'rounded-corner\'>';

/* thead - start */
$myresult .= '<thead>';

$myresult .= '<tr>';

$myresult .= '<th width=\'30%\' class=\'rounded-company\' scope=\'col\'><span style=\'font: normal 18px  Arial, Helvetica, sans-serif; color:#FFF;\'>Ratings</span></th>';

$myresult .= '<th width=\'70%\' colspan=\'2\'class=\'rounded-q4\' scope=\'col\'></th>';

$myresult .= '</tr>';
$myresult .= '</thead>';

/* thead - end */

/* tbody - start */
$myresult .= '<tbody>';
unset($i);
/*start printing the table wth feature and ratings */
for ($i = 1 ; $i < $numProperties; $i++){

if($master_rating_properties['rating'.$i.'_name']){

$myresult .= '<tr>';

/*fetch ratings and comments - 1st make it to null */
$indfeature = 0;
$comment    = '';

$indfeature = $user_ratings['rating'.$i];
if($indfeature == NULL){ $indfeature = 0; }
$comment    = $user_ratings['rating'.$i.'_comment']; 


$myresult .= '<td width=\'22%\'>';

$myresult .= $master_rating_properties['rating'.$i.'_name'].' ( '.$indfeature.' )';

$myresult .= '</td>';

$myresult .= '<td colspan=\'0\' width=\'38%\' >';

if(($userId != '0') && (is_array($user_ratings)))
{
$tocheck = $indfeature;
}
else
{
$tocheck = '0';
}

for($k = 0.5; $k <= 10.0; $k+=0.5){

$tocheck = roundOff($tocheck);
if(($tocheck) == $k)
{ $chk = "checked"; }

else

{ $chk = ""; }

$myresult .= '<input class=\'star {split:2}\' type=\'radio\' name=\'rating'.$i.'\' id=\'rating'.$i.''.$k.'\' value=\''. $k .'\'  '.$chk.'  title=\''. $k.' out of 10 \' '.$disabled.' \' />';

}

/* for k loop end */
$myresult .= '</td>';
$myresult .= '<td width=\'40%\'>';
$myresult .= '<input title=\'Reason for this Rating.. \'type=\'text\' size=\'25\' name=\'comment'.$i.'\' id=\'comment'.$i.'\' style=\'display:;\' maxlength=\'255\' value="'.$comment.'">';
$myresult .= '</td>';
$myresult .= '</tr>';
}
/* end if loop */
}
/* end i for loop */

$myresult .= '</tbody>';
/* end tbody */    

/* footer round corner start */
$myresult .= '<tfoot>';
$myresult .= '<tr>';
$myresult .= '<td class=\'rounded-foot-left\'>&nbsp;</td>';

$myresult .= '<td class=\'rounded-foot-right\' colspan=\'4\' >';

if(($userId != '0') && (is_array($user_ratings)))
{
$myresult .= '<input type=\'button\' id=\'update_form\' value=\'Update\'>';
}
else
{
$myresult .= '<input type=\'button\' id=\'save_form\' value=\'Save\'>';
}

$myresult .= '</td>';
$myresult .= '</tr>';
$myresult .= '</tfoot>';

$myresult .= '</table>';
/*round corner table end */

$myresult .= '</form>';
/*end the form to take ratings */ 
$myresult .= '</div>';
/*end 2nd tab */

1 个答案:

答案 0 :(得分:1)

使用jquery post,您可以返回JSON数据并使用jquery html method更新组件数据。它只是和想法