gpt4 book ai didi

javascript - Codeigniter JQuery 在 jquery .get 请求后动态加载 View 中的数据

转载 作者:行者123 更新时间:2023-12-01 05:43:38 26 4
gpt4 key购买 nike

我一直在思考,但我无法让它发挥作用。所以我有一个 Jquery 函数,在输入字段 onblur 事件之后在数据库中发布新的折扣值。

JQuery:

    function saveAtlProc(t){
pzid = $('#pzrows').attr('rel');
atl_proc = $(t).val();
var site_url = document.getElementById("site_url").value;
$.post(site_url, {
pzid : pzid,
atl_proc : atl_proc,
site_url : site_url
},
function(rawdata){
getPZtotals();
});
}

这有效并且没问题,问题始于 getPZtotals(),

getPZtotals() JQuery:

function getPZtotals(){
pzid = $('#pzrows').attr('rel');
var site_url = document.getElementById("pvn_rates_get").value;
$.get(site_url, {
pzid : pzid
},
function(rawdata){
var pieg_nos = rawdata.pieg_nos;
alert(pieg_nos);
});
}

警报函数显示该变量未定义。我不明白为什么。

这是 .get() 使用 firebug 检查它时返回的内容

[{"ID":"123","avr":"0","avrnr":"1502193","avrdat":"2015-03-15","avrproc":"0.00","pz":"","serija":"","numurs":"","datums":"0000-00-00","parvad":"P\u0101rvad\u0101t\u0101js: klienta transports","apm_not":"","apm":"","piez":"Jauns pied\u0101v\u0101jums","pieg_id":"667","pieg_nos":"Miks Ratnieks SIA","reg_nr":"RE\u0122ISTR\u0100CIJASNR","pvn_id":"PVNSNR","pieg_jadr":"Uliha 68-1","pieg_fadr":"Kurmja pieg\u0101des32-1","pieg_iban":"LV34012389072345987","pieg_swift":"SWED8927348","pieg_banka":"SWEDBANK","valuta":"EUR","summa":"300.00","atl_proc":"2.00","atl_summa":"6.00","summa_bpvn":"294.00","pvn":"63.00","summa_arpvn":"363.00","apm_datums":"0000-00-00","datetime":"2015-03-19 13:04:22","avanss":"","avanss_txt":"","avanss_sum":"0.00","avanss_apm":"0.00","arpvn":"","komentars":"","nol":"","statuss":"Iesakts","autors":"","pvn_summa_0":"0","pvn_summa_1":"0","pvn_summa_2":"0","pvn_likme_0":"0","pvn_likme_1":"21","pvn_likme_2":"12","pvn_0":"0","pvn_1":"0","pvn_2":"0"}]

我认为这是正确的,不应该有任何问题。

我的 Controller :在 .get() 函数中返回数据

  public function get_new_discounts(){
$this->load->model('offers_for_clients_model');
$id = trim($_GET['pzid']);
$data['orders_info'] = $this->offers_for_clients_model->get_offers_info($id);
$this->output->set_output(json_encode($data['orders_info']));
/*echo ();*/
}

型号:

function get_offers_info($id){
$query = $this->db->where('ID', $id)->get('pz_pied')->result();
return $query;
}

我用谷歌搜索但找不到与此类似的内容。

最佳答案

您的 PHP 模型正在返回一个外部数组,其中包含您尝试在警报中访问的对象数据。

尝试:

 var pieg_nos = rawdata[0].pieg_nos;
alert(pieg_nos);

关于javascript - Codeigniter JQuery 在 jquery .get 请求后动态加载 View 中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29143092/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com