$(document).ready(function()
{
var ad_id =/*$("#ad_id").val() */<?php echo $ad['id']; ?>;
var uid = /*$("#ad_id_poster").val()*/ <?php echo $ad['uid']; ?>;
$.ajax(
{
type:'POST',
url:'../business_logic/answer.php', //URL
data:{ id: ad_id, ad_uid:uid}, //Data
beforeSend:function(){
$('#wait').show();
},
success:function(data,status){ //Data,status
var item = $(data).hide().slideDown("slow");
$('#wait').hide();
$('.all_qa_updates').prepend(item);
// reset form and button
$('#cmnt_in').val('');
}
});
});
此代码从answer.php文件返回数据
$n = null;
$id = $_POST['id'] ; //Ad Id
$ad_uid = $_POST['ad_uid']; //Ad poster ID
$QueAns = new QueAns($n,$n,$n,$n,$n,$n,$n);
$all_aq = $QueAns->get_ques($id); //param ad id
$current_u = $_SESSION['uid'];
if(isset($all_aq) === true)
{
for( $i = 0 ; $i < count($all_aq) ; $i++ )
{
$name = $all_aq[$i]['u_fn'].' '.$all_aq[$i]['u_ln'];
$q = $all_aq[$i]['q_ques'];
$path = $dp_path.$all_aq[$i]['u_img'];
$check_ans = $all_aq[$i]['ans']['fn'];
?>
<div class="all_qa panel panel-default">
<img src="<?php
if(isset($all_aq[$i]['u_img'])){
echo $path;
}
else{
echo '../images/default_profile_pic/d_boy.png';
}
?>">
<a href="#"><?php echo $name;?></a><br>
<p><?php echo $q;?></p>
<?php
/* if((isset($all_aq[$i]['ans']['fn']) === true) && (isset($_SESSION['uid']) === true))
{
echo '</div>';
} */
if(isset($check_ans))
{?>
</div>
<?php //echo 'ans';
$a_name = $all_aq[$i]['ans']['fn'].' '.$all_aq[$i]['ans']['ln'];
$a_ans = $all_aq[$i]['ans']['ans'];
$a_path = $dp_path.$all_aq[$i]['ans']['u_img'];
echo '<div class="ans panel panel-default">';
echo '<img src="'.$a_path.'">';
echo "<a href='#'>".$a_name."</a><br>";
echo '<p>'.$a_ans.'</p>';
echo '</div>';
}
if(isset($check_ans) === false &&
$ad_uid === $current_u)
{
echo '<p>reply</p>';
echo '<input value="Reply" type="button" data-toggle=btn_'.$all_aq[$i]['q_id'].' id="reply">';
?>
</div>
<form class="answer_form" id="btn_<?php echo $all_aq[$i]['q_id'];?>">
<img src='../images/default_profile_pic/d_boy.png'>
<textarea id="cmnt_in" type="text" name="comment" placeholder="Ask Question..." required></textarea>
<input value="POST" type="button" id="send_data" onclick="send_data" class="btn p_srch">
<input type="hidden" id="q_id" value="<?php echo $all_aq[$i]['q_id'];?>" />
</form>
<?php
}
}
}
问题是,当jquery返回数据时,它会跳过第一个div以及它的结束div ....请帮助。
另一个奇怪的事情是,当我明确地为变量id和ad_id赋值时,返回数据完全按照我想要的方式显示,并且没有丢失任何div,但是当它从帖子中获取时跳过一些div.pls帮助