0

I'm getting this error Uncaught TypeError: Illegal invocation

I've tried to parse it

here's script

function Addpayment(or_number, customer_no) { 
        var or_number   = $("#or_number").val(or_number);
        var customer_no = $("#customer_no").val(customer_no);

        $.ajax({
            url:"<?php echo base_url('dashboard/addpaymenttable') ?>",
            data:{ or_number:or_number,customer_no:customer_no},
            type:"POST",
            success: function(data){
            //    data = JSON.parse(data);

                alert(data.or_no);
                console.log(data);
            }
        });
}

AND heres my cotroller

// $result = $this->M_dashboard->GetPayment($customer_no,$or_no);
 // echo $result;

And here's my model

  $query = $this->db->select("*")->from("customer_payment")->where("or_no",$or_no)->where("customer_no",$customer_no)->get();
    // $data =[];
   foreach($query->result_array() as $row){
        // print_r($row['or_no']);
        $data = [

            "or_no"=>$row['or_no'],
            "customer_no"=>$row['customer_no'],
            "date_of_transaction"=>$row['date_of_transaction'],
            "payment_type"=>$row['payment_type'],
            "payment_for"=>$row['payment_for'],
            "price"=>$row['price'],
            "process_by"=>$row['process_by'],
            "status" =>$row['status'],  

        ];

   }

   return json_encode($data);
Phil
  • 157,677
  • 23
  • 242
  • 245
Noodles
  • 11
  • 5
  • What exactly are you trying to do with `var or_number = $("#or_number").val(or_number)`? jQuery's [`.val(value)`](https://api.jquery.com/val/#val2) returns a `jQuery` object so trying to put `or_number` and `customer_no` in your request data isn't going to work very well. – Phil Aug 06 '19 at 06:04
  • yes it throw object – Noodles Aug 06 '19 at 06:06
  • I suspect you actually want `var or_number = $("#or_number").val()` (same for `customer_no`). See [`.val()`](https://api.jquery.com/val/#val1) – Phil Aug 06 '19 at 06:06
  • function Addpayment(or_number,customer_no) { here's the function name } – Noodles Aug 06 '19 at 06:07
  • In that case, remove the `var or_number =` and `var customer_no =` – Phil Aug 06 '19 at 06:08
  • should i edit my controller too? – Noodles Aug 06 '19 at 06:09
  • I got an error "undefine variable" "data" which is in my model – Noodles Aug 06 '19 at 06:27
  • [“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP](https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined) – Phil Aug 06 '19 at 06:28

0 Answers0