php - Ajax is not working in Codeigniter -


ajax not working : want update 1 record using code igniter framework. when passing po_id below url. ajax not working. without passing id below ajax working.

<a class="btn btn-success" href="<?php echo base_url('inventory_c/view_purchase_update/'.$result->po_id);?>">update</a> 

controller:

public function view_purchase_update() {       $data['pitems'] = $this->inventory_m->purchase_items_update($po_id);       $data['sname']  = $this->inventory_m->getsuppname($supplier_id);       $data['sid'] = $this->inventory_m->getsuppid($po_id);             $this->load->view('superadmin/editable_purchase_update',$data);      } 

ajax code:

$.ajax({       type: "post",       url: "add_temp_purchase",       cache: false,       data: 'itemnum='+itemnum+'&itemname='+itemname+'&costprice='+costprice+'&quantity='+quantity+'&customer_id='+customer_id+'&sales='+sales,       datatype: "html",       success: function(returnhtml) {        } }); 

when sending data ajax mind it's json formatted.

what can below:

$.post( "add_temp_purchase", {        itemnum: itemnum,        itemname: itemname,       costprice: costprice,       quantity: quantity,       customer_id: customer_id,       sales: sales }).success(function( data ) {      alert( "success" ); }); 

in controller have follwing

public function postdata() {      $postdata = $this->input->post();      $itemnum = $postdata['itemnum'];      #etc.... } 

aswell can confirm can print out $result->po_id in view? seems never parse view, in controller should following make sure have this

public function view_purchase_update() {   $data['pitems'] = $this->inventory_m->purchase_items_update($po_id);   $data['sname']  = $this->inventory_m->getsuppname($supplier_id);   $data['sid'] = $this->inventory_m->getsuppid($po_id);      $data['po_id'] = $po_id;   $this->load->view('superadmin/editable_purchase_update',$data);      } 

then in view use this

<a class="btn btn-success" href="<?= base_url('inventory_c/view_purchase_update/'.$po_id);?>">update</a> 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -