Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery GetJSON在Opera中工作吗? $.getJSON('http://www.thesite.net/api.php,函数(数据){ 如果(data.status!=401) { 如果(data.messages==0) { $('#messages').html('无新消息'); } 其他的 { $('#messages').html(data.messages+'新消息'); } $('#currency').html(data.cashfmt+'Bux'); } 其他的 { $('#container').html('您未登录该网站。请'); } });_Jquery - Fatal编程技术网

Jquery GetJSON在Opera中工作吗? $.getJSON('http://www.thesite.net/api.php,函数(数据){ 如果(data.status!=401) { 如果(data.messages==0) { $('#messages').html('无新消息'); } 其他的 { $('#messages').html(data.messages+'新消息'); } $('#currency').html(data.cashfmt+'Bux'); } 其他的 { $('#container').html('您未登录该网站。请'); } });

Jquery GetJSON在Opera中工作吗? $.getJSON('http://www.thesite.net/api.php,函数(数据){ 如果(data.status!=401) { 如果(data.messages==0) { $('#messages').html('无新消息'); } 其他的 { $('#messages').html(data.messages+'新消息'); } $('#currency').html(data.cashfmt+'Bux'); } 其他的 { $('#container').html('您未登录该网站。请'); } });,jquery,Jquery,这是我有一些小修改的代码。它被HTML文档中的标记包围。它将在扩展中使用。当我制作扩展并使用它时,它在Chrome中工作得非常好,但是在Opera的同一个文档中,我检查了多次,这就是问题的原因。页面运行后仍未编辑。页面的其余部分非常简单,只有很少的JS。没有特定于铬的方法。出于某种原因,这在歌剧中不起作用。我尝试添加一行来检查它是否只是忽略了ifs,但我发现它甚至忽略了第一行之后的行(我这样做时它在Chrome中工作得非常好),Opera不接受getJSON吗 GetJSON在Opera中工作吗

这是我有一些小修改的代码。它被HTML文档中的标记包围。它将在扩展中使用。当我制作扩展并使用它时,它在Chrome中工作得非常好,但是在Opera的同一个文档中,我检查了多次,这就是问题的原因。页面运行后仍未编辑。页面的其余部分非常简单,只有很少的JS。没有特定于铬的方法。出于某种原因,这在歌剧中不起作用。我尝试添加一行来检查它是否只是忽略了ifs,但我发现它甚至忽略了第一行之后的行(我这样做时它在Chrome中工作得非常好),Opera不接受getJSON吗

GetJSON在Opera中工作吗

如果需要cookie共享,请将此行添加到扩展名的
config.xml

$.getJSON('http://www.thesite.net/api.php', function(data) {
    if (data.status != 401)
    {
        if (data.messages == 0)
        {
            $('#messages').html('No New Messages');
        }
        else
        {
            $('#messages').html(data.messages + ' new messages. <a href="javascript:go_to_messages();">Check</a>');
        }
        $('#currency').html(data.cashfmt + '  Bux');
    }
    else
    {
        $('#container').html('You are not logged into the site. Please <a href="javascript:go_to_login();">login</a>.');
    }
});
但是,您应该更加明确,并且应该使用:

<access origin="*"/>
链接到文档:

jQuery解决方案2:

从jQuery1.5开始,您必须强制执行跨站点脚本

$.getJSON("http://www.thesite.net/api.php?callback=?", function (data)
{
    ...
});

看看这个答案:

<access origin="http://thesite.net/" subdomains="true"/>
<access origin="https://thesite.net/" subdomains="true"/>
$.getJSON("http://www.thesite.net/api.php?callback=?", function (data)
{
    ...
});
$.support.cors = true;
jQuery.support.cors = true;