Jquery ';SyntaxError:应为表达式,Get<';来自$.getScript

Jquery ';SyntaxError:应为表达式,Get<';来自$.getScript,jquery,plugins,getscript,Jquery,Plugins,Getscript,我想创建一个jQuery多语言插件。我还想打开插件函数中包含“object”的语言文件并访问其内容 $.getScript('lang/' + settings.language + '.js').done(function() { console.log('loaded this'); }).fail(function() { consoleError('language file does not exist!'); }); 上面的代码给出了以下错误 SyntaxError:预期表

我想创建一个jQuery多语言插件。我还想打开插件函数中包含“object”的语言文件并访问其内容

$.getScript('lang/' + settings.language + '.js').done(function() {
  console.log('loaded this');
}).fail(function() {
  consoleError('language file does not exist!');
});
上面的代码给出了以下错误


SyntaxError:预期表达式,得到“我的假设是您引用的脚本不正确,web服务器正在提供404 html页面。
更改代码如下:

        jQuery.ajax({
                    type: "GET",
                    url: 'lang/' + settings.language + '.js',
                    dataType: "script",
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        consoleError('language file does not exist!');
                    },
                    success:function(){
                        console.log('loaded this');
                    }
                });

该错误通常表示您正在
getScript()
调用中加载HTML-通常是由于返回了错误页面而不是预期的脚本。检查控制台中的实际响应。js文件包含