[英]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.