Welcome Guest, Not a member yet? Register   Sign In
Onchange function using ajax in View

Hi! I've an autocomplete input form with id 'poscustomer' . I want to display previous total balance whenever I select a customer.
I tried this but no results. would you please tell me which part of this code needs to be edited . Thanks

function dispdata()

    $poscustomer = $this->input->post('poscustomer',TRUE);
        $data['totalbalance'] =$this->pos_model->getBalance($poscustomer)->result();
    echo json_encode($data);

public function getBalance($poscustomer)
      $this->db->select('SUM(grand_total - paid) as totalbalance', false);
      $this->db->where('sales', array('customer' => $poscustomer));
      return $result->totalbalance;

Javascript code in the view folder
  var poscustomer=$(this).val();
url    : "<?=admin_url('pos/dispdata');?>",
type: "POST",
data : {poscustomer: poscustomer},
cache: false,
dataType: 'json',
        success: function(data){


Messages In This Thread
Onchange function using ajax in View - by jordi_1h - 04-20-2020, 09:48 PM

Theme © iAndrew 2016 - Forum software by © MyBB