收到了一个无效的响应。因此,原点“null”不允许访问。

时间:2022-10-14 17:01:13

I am following a book example hence the code is very simple. This is the code:
I see an error in Chrome console:

我正在遵循一个图书示例,因此代码非常简单。这是代码:我在Chrome控制台看到一个错误:

$(function() {
    $(".lang").change(function(){

    var element = $(this);

    var id = element.attr("value");

    if(id == 'english')
    {
        $.ajax({
            type: "GET",
            url: "jsfiles/english.js",
            dataType: "script"
        }); 
    }

    return false;

    });

});

1 个解决方案

#1


14  

Origin null means you are loading the HTML document directly from your file system. You can't use XMLHttpRequest without HTTP.

Origin null表示直接从文件系统加载HTML文档。如果没有HTTP,就不能使用XMLHttpRequest。

Either install a web server for your development, or dynamically generate a <script src="..."></script> instead.

要么为您的开发安装web服务器,要么动态生成一个

#1


14  

Origin null means you are loading the HTML document directly from your file system. You can't use XMLHttpRequest without HTTP.

Origin null表示直接从文件系统加载HTML文档。如果没有HTTP,就不能使用XMLHttpRequest。

Either install a web server for your development, or dynamically generate a <script src="..."></script> instead.

要么为您的开发安装web服务器,要么动态生成一个