jquery post 返回php,如何在成功的AJAX / jQuery POST上返回PHP变量
如何使用AJAX在PHP中返回變量?我目前在我的控制器中使用echo在下拉列表中顯示價(jià)格.在一個(gè)名為price的div中顯示.
但是我有一個(gè)隱藏字段,我需要將行ID返回到更改.如何在jQuery中分配return var以便我可以在隱藏字段中回顯它?
jQuery的
$(document).ready(function() {
$('#pricingEngine').change(function() {
var query = $("#pricingEngine").serialize();
$('#price').fadeOut(500).addClass('ajax-loading');
$.ajax({
type: "POST",
url: "store/PricingEngine",
data: query,
success: function(data)
{
$('#price').removeClass('ajax-loading').html('$' + data).fadeIn(500);
}
});
return false;
});
});
調(diào)節(jié)器
function PricingEngine()
{
//print_r($_POST);
$this->load->model('M_Pricing');
$post_options = array(
'X_SIZE' => $this->input->post('X_SIZE'),
'X_PAPER' => $this->input->post('X_PAPER'),
'X_COLOR' => $this->input->post('X_COLOR'),
'X_QTY' => $this->input->post('X_QTY'),
'O_RC' => $this->input->post('O_RC')
);
$data = $this->M_Pricing->ajax_price_engine($post_options);
foreach($data as $pData) {
echo number_format($pData->F_PRICE / 1000,2);
return $ProductById = $pData->businesscards_id;
}
}
視圖
這是我的隱藏字段,我希望每次更改表單時(shí)都要傳遞VAR.
“/>
謝謝您的幫助!
總結(jié)
以上是生活随笔為你收集整理的jquery post 返回php,如何在成功的AJAX / jQuery POST上返回PHP变量的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: matlab潮流程序,IEEE33节点m
- 下一篇: php系统升级说明,PHPCMF内容管理