我有这个jQuery
ajax:
$.ajax({
type: 'POST',
url: 'test.php',
cache: false,
data: 'action=find'+'&find_date=' + find_date + '&find_title='+ find_title +
'&find_datestart='+ find_datestart + '&find_dateend='+ find_dateend +
'&find_locationid='+ find_locationid + '&find_userid='+ find_userid +
'&find_roomid='+ find_roomid +
'&find_starttime='+ find_starttime + '&find_endtime='+ find_endtime,
success: function(response){
alert(response);
$("#find").dialog('close');
$('.remove').remove();
$('#find_data').before('abcccccc');
//location.reload();
return false;
}
});
这是我的HTML
foreach($GetSchduleData as $k => $schedule) {
?>
<tr style="text-align: center;" class="remove">
<input type="hidden" name="class_id" value="<?php echo $schedule['class_id']; ?>">
<input type="hidden" name="class_type_id" value="<?php echo $schedule['class_type_id']; ?>">
<input type="hidden" name="type_description_abbr" value="<?php echo $schedule['type_description_abbr']; ?>">
<td class="scheduletd"><input type="checkbox" title="selectUnselect" onclick="" id="selectUnselect"></td>
<td class="scheduletd"><?php echo $i; ?></td>
<td class="scheduletd"><?php echo $schedule['timestart'];?></td>
<td class="scheduletd"><?php echo $schedule['timeend'];?></td>
<td class="scheduletd"><div class="type_meeting <?php echo $schedule['type_description_abbr'] ?>" id="<?php echo $schedule['class_id'];?>type"></div> </td>
<td class="scheduletd"><?php echo $schedule['s_title'];?></td>
<td class="scheduletd"><?php echo $schedule['instructor'];?></td>
<td class="scheduletd">Sub?</td>
<td class="scheduletd"><?php echo $schedule['location_name'];?></td>
<td class="scheduletd"><?php echo $schedule['class_room'];?></td>
<td class="scheduletd"><?php echo $schedule['Show_online'];?></td>
<td class="scheduletd"><?php ?>Product</td>
<td ><?php ?>Enrolled</td>
</tr>
<?php
$i++;
}
?>
<tr id="find_data">
</tr>
我希望使用响应成功替换此tr
作为回应,我得到array
,但我希望在成功中进行for
循环。怎么可能?
答案 0 :(得分:0)
像
一样使用它 $.ajax({
type: 'POST',
url: 'test.php',
cache: false,
dataType: "json",
data: 'action=find' + '&find_date=' + find_date + '&find_title=' + find_title +
'&find_datestart=' + find_datestart + '&find_dateend=' + find_dateend +
'&find_locationid=' + find_locationid + '&find_userid=' + find_userid +
'&find_roomid=' + find_roomid +
'&find_starttime=' + find_starttime + '&find_endtime=' + find_endtime,
success: function (response) {
for (i = 0; i < response.length; i++) {
alert(response[i].class_id);
}
$("#find").dialog('close');
$('.remove').remove();
$('#find_data').before('abcccccc');
//location.reload();
return false;
}
});