简体   繁体   English

带load()的jquery-issue:适用于Firefox和Safari,不适用于Chrome,Opera和IE

[英]jquery-issue with load(): works with Firefox and Safari, not with Chrome, Opera and IE

May somebody could take a look at this. 可能有人可以看看这个。 With Firefox and Safari it works, but not with Chrome, IE and Oopera... and I don't know why. 使用Firefox和Safari可以使用,但不能使用Chrome,IE和Oopera ...,我不知道为什么。

After a click in a table, it fetches the id and will build a url which will be loaded. 在表中单击后,它将获取ID并构建一个将被加载的URL。 Actually I will pass arrays with load to the php, but for the demonstration, I guess this example makes more sense: 实际上,我会将带有负载的数组传递给php,但是对于演示,我想这个例子更有意义:

var id1 = "1";
var id2 = "2";

oTable.$('tr').click(function () {
    isClicked = $(this).data('clicked');
    if (isClicked) {
        isClicked = false;
    } else {
        isClicked = true;
    }
    $(this).data('clicked', isClicked);

    if (isClicked) {
        id2 = id1;
        id1 = oTable.fnGetData(this, 0);
        $(window).scrollTo('#ma', {
            duration: 1000
        });
        $("#ma").fadeOut('slow', function () {
            $("#ma").fadeIn('slow').load("index" + id1 + id2 + ".html");
        });
    } else {
        id2 = id1;
        id1 = oTable.fnGetData(this, 0);
        $(window).scrollTo('#ma', {
            duration: 1000
        });
        $("#ma").fadeOut('slow', function () {
            $("#ma").fadeIn('slow').load("index" + id1 + id2 + ".html");
        });
    }
}); 

What happens in all browsers: After a click in a row it will scroll to the id #ma (so the functions work in a toggle way), but only Firefox and Safari will load the file. 在所有浏览器中会发生什么:连续单击后,它将滚动到ID #ma(因此功能以切换方式工作),但是只有Firefox和Safari会加载该文件。

What's wrong with it? 它出什么问题了? Or is it an issue with the ids in the url, and will be okay, when I push it as arrays to the php? 还是URL中的ids有问题,当我将其作为数组推送到php时会好吗? So far I tried it only in local modus. 到目前为止,我仅以本地方式尝试过。

adeneo gave the hint: The script is fine, but I "can't make ajax requests from a file:: protocol". adeneo给出了提示:脚本很好,但是我“无法从file ::协议发出ajax请求”。 I tried to load the file from a local folder. 我试图从本地文件夹加载文件。 Obviously the 3 browsers don't like it... and Firefox and Safari just ignore it. 显然,这3种浏览器不喜欢它,而Firefox和Safari只会忽略它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 jQuery .css()在IE 6,7,8和Firefox中不起作用,但在Chrome,Safari,Opera中起作用 - jQuery .css() not working in IE 6,7,8 and Firefox, but works in Chrome, Safari, Opera jQuery可以在Firefox,Safari和Opera中运行,但不能在IE中运行吗? - Jquery works in Firefox, Safari & Opera but not IE? jQuery jPlayer.event.ended在Chrome,Safari,IE9中有效,但在Opera和FireFox中无效 - jQuery jPlayer.event.ended works in Chrome, Safari, IE9, but NOT Opera and FireFox jQuery AJAX在任何IE中均不起作用,但在Firefox,Opera,Chrome和Safari中运行良好 - jQuery AJAX not working in any IE, but fine in Firefox, Opera, Chrome and Safari Firefox和Chrome,Opera上的jQuery Ajax问题(在Safari上运行良好) - jQuery Ajax problems on Firefox and Chrome, Opera (works well on Safari) Javascript / jQuery无法在Firefox,Safari和IE中运行。 精通Opera和Chrome - Javascript/jQuery not working in Firefox, Safari and IE. Fine in Opera and Chrome 为什么我的JQuery可以在Firefox / Opera中运行,而不能在Chrome / Safari / IE中运行? - Why does my JQuery work in Firefox/Opera, but not Chrome/Safari/IE? jQuery width()在Opera中不起作用,但在FF,IE,Chrome,Safari中起作用 - jQuery width() not working in Opera but works in FF, IE, Chrome, Safari jQuery ajax调用WebApi可在IE上运行,但不能在Firefox,Chrome或Opera上运行 - jQuery ajax call to WebApi works on IE but not Firefox, Chrome or Opera 我有用于通过ajax或jquery更新mysql的表,并且适用于firefox,opera,chrome和safari,但不适用于IE8 - I have table that i use to update mysql via ajax or jquery and works for firefox,opera,chrome and safari but not IE8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM