Question

I'm receiving Uncaught Syntax Error: Unexpected token= error in chrome browser only and the error pointing near by my function

function updateSalesQty(id_sale,id_product,id_customer,sign=0,qty=0)
    {

Error pointing here

$.ajax({
                type:'POST',
                url: 'index.php?controller=AdminCarts&token=fc9ff5f59559a3d4137b247a768bf320',
                data : {
                    ajax: '1',
                    token: 'fc9ff5f59559a3d4137b247a768bf320',
                    tab: 'AdminCarts',
                    action: 'updateSaleQty',
                    id_sale: id_sale,   
                    id_product: id_product,     
                    id_customer: id_customer,               
                    sign:sign,  
                    qty:qty,                                
                },
                success : function(res)
                {
                  $('#customer_sale tbody').html(res);
                }
            });

        }
Was it helpful?

Solution

function updateSalesQty(id_sale,id_product,id_customer,sign=0,qty=0)

So far, only firefox supports default arguments in JS. You'd have to set the defaults inside of the function, for example like

sign = sign || 0;

or

qty = (typeof qty !== 'undefined') ? qty : 0;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top