0
在我看來,我有以下幾點:如何發送多個元素作爲Ajax響應CakePHP中2.0.6
<script type="text/javascript">
$(function() {
$('.go_button').click(function(e){
e.preventDefault();
$.ajax({
type: "POST",
url: "/Controller/find_by_location",
data: "city=New%York",
dataType: 'html',
success: function(data) {
$('#coupons_results').html(data);
}
});
});
});
</script>
在我的控制器:
public function find_by_location(){
$this->autoRender = false;
$this->TblLocalDeal->recursive = 3;
$city = "New york"; //just for test
$zipcode = ""; //testing
$conditions = array(...);
$result = $this->paginate('Table', $conditions);
$this->layout = null;
foreach($results as $result):
$this->set('var', $result['index']);
$this->render('/elements/local_coupon');
endforeach;
}
這只是發送的HTML中第一個元素。我如何發送所有在foreach中呈現的其他元素的html?
謝謝。