Get undefined javascript function in IE 11

孤街醉人 提交于 2019-12-02 07:23:45

The function declaration for calculate_amount is wrong. You are trying to use es6 in ie11.

function calculate_amount(currency = 'IDR') // this will work only in chrome and firefox 

Unfortunately IE didn't throw an error. That is the reason your event handler is not reachable.

change it to

function calculate_amount(currency) 
{
    currency = currency || 'IDR'; //if your intent is to set a default value for currency
    //alert("ok");
    var nights = $('[name="nights"]').val();
    var total_amount = 0; var total_room_qty = 0; var total_qty_room_id = 0;

    console.log('nights: '+nights);


    return total_room_qty;
}

example https://jsfiddle.net/karthick6891/0681reux/

I was also having a similar error and Google brought me here.

In my case, it was also a syntax incompatibility problem with older versions of IE: the use of arrow functions (=>) is not supported.

In order to solve it, see Syntax error in IE using ES6 arrow functions.

Unfortunately, IE was telling me that the function below this expression was undefined, so it took a while to find out what was the actual error.

I hope this can save time to others with the same problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!