ReferenceError:endsWith未定义

时间:2016-02-02 12:29:43

标签: javascript java jsp extjs extjs3

在我的代码中,我试图在extjs 3.4中使用jmaki调用来调用.jsp文件。这是我的代码。

function redirectToOrderWizard(){

    jmaki.doAjax({ 
        url : 'services/GotoOrderDetailService.jsp',
        method : 'POST',
        asynchronous : false,
        callback: function(response) {
            console.log('redirectToOrderWizard1');
            var resObj = Ext.decode(response.responseText);
            if(resObj.goeLink.trim() == ''){
                console.log('redirectToOrderWizard2');
                window.top.location = '../../bpmportal/login.jsp';
            }else{
                console.log('redirectToOrderWizard3');
                if(undefined == myWindow || null == myWindow || '' == myWindow || myWindow.closed){
                    console.log('redirectToOrderWizard4');
                    myWindow = window.open(resObj.goeLink, "_blank");
                } else {
                    console.log('redirectToOrderWizard5');
                    top.Ext.MessageBox.alert('Alert', 'There is another window open for any other order in edit mode, so please close it first to access your selected order.');
                    return false;
                    /*myWindow.close();
                    myWindow = window.open(resObj.goeLink, "_blank");*/
                }
            }
        },
        onerror:  function handleError(msg,_req){
            top.Ext.MessageBox.alert('Failure','Failed to open Order Entry Wizard to selected Job due to technical problem(s).');
            jobDetailGrid.getStore().reload();
        }
    });

}

这是我在firebug中得到的原始错误。行号为3或4的实际错误点。那是我做错的事吗?

this.doAjax= function(args) {
   /*********  Fix for PCT-1216 (Starts)   ****/
   if(args.url != 'undefined' && endsWith(args.url,'config.json')) {
        args.url = getContextPath() + '/resources/config.json';
   }
   /*********  Fix for PCT-1216 (End)   ****/
   if (typeof args == 'undefined' || !args.url) {
       _jmaki.log(_jmaki.getMessage("ajax_url_required"));
       return;
   }
  ....
};

1 个答案:

答案 0 :(得分:0)

endsWith属于String原型,不属于全局范围,因此您应该使用:

args.url.endsWith('config.json')

而不是endsWith(args.url, 'config.json')

以下是docs