我的Smarty模板如下:
<form id="view-transactions-form" name="user_transactions_status" action="{$control_url}modules/transactions/view_transactions.php" method="post">
<input type="hidden" name="from_date" value="{$from_date}"/>
<input type="hidden" name="to_date" value="{$to_date}"/>
<input type="hidden" name="transaction_status" value="{$transaction_status}"/>
<input type="hidden" name="transaction_no" value="{$transaction_no}"/>
<div class="trans_menu">
<ul class="trans_menuul">
<li>
<a href="#" class="blue_active">
<div>
<div class="checkbxd"><input class="custom-check" type="checkbox" name="cancelled" id="cancelled" onChange="return submitForm();"></div>
<div class="checkbxd_txt">Cancelled : {$user_transactions_count.cancelled_transaction_count}</div>
</div>
</a>
</li>
<li>
<a href="#" class="green">
<div>
<div class="checkbxd"><input class="custom-check" type="checkbox" name="success" id="success" onChange="return submitForm();"></div>
<div class="checkbxd_txt">Success : {$user_transactions_count.success_transaction_count}</div>
</div>
</a>
</li>
<li>
<a href="#" class="yellow">
<div>
<div class="checkbxd"><input class="custom-check" type="checkbox" name="inprocess" id="inprocess" onChange="return submitForm();"></div>
<div class="checkbxd_txt">Inprocess : {$user_transactions_count.inprocess_transaction_count}</div>
</div>
</a>
</li>
<li>
<a href="#" class="red">
<div>
<div class="checkbxd"><input class="custom-check" type="checkbox" name="failed" id="failed" onChange="return submitForm();"></div>
<div class="checkbxd_txt">Failed : {$user_transactions_count.failed_transaction_count}</div>
</div>
</a>
</li>
</ul>
</div>
</form>
ajax调用如下:
{literal}
<script language="javascript" type="text/javascript">
function submitForm() {
var form = document.user_transactions_status;
var dataString = $(form).serialize();
$.ajax({
type:'POST',
url:'view_transactions.php',
data: dataString,
success: function(data) {
}
});
return false;
}
</script>
{/literal}
PHP代码如下:
list( $grid_data, $transaction_count_data, $sort_status, $sort_link_array, $pag_link_array ) = get_all_user_transactions($request,$cur_page, $sort_col_id ,$desc_or_asc, $where_str, $query_string);
//print_d($grid_data);
list( $grid_data ) = prepare_response($grid_data);
list( $transaction_count_data ) = prepare_response($transaction_count_data);
$smarty->assign('user_transactions', $grid_data);
$smarty->assign('user_transactions_count', $transaction_count_data);
$smarty->assign('cur_page', $cur_page);
die();
如果我在firebug控制台中看到但无法在网页上显示,我能够获得所需的数据。有人可以在这方面指导我吗?
答案 0 :(得分:1)
在ajax成功函数中,将数据放在要显示它的位置 EX:显示div中的响应数据
<div id="display"></div>
$.ajax({
type:'POST',
url:'view_transactions.php',
data: dataString,
success: function(data) {
$('#display').html(data);
}
});