在IE7 jQuery的AJAX的问题(可能还有其他版本一样) [英] jQuery AJAX problem in IE7 (possibly other versions as well)

查看:200
本文介绍了在IE7 jQuery的AJAX的问题(可能还有其他版本一样)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能开导我,为什么下面的code将无法在IE7中工作,但它工作得很好,在Chrome / Firefox的?

  $(文件)。就绪(函数(){
  $阿贾克斯({
    键入:POST,
    数据类型:文本,
    缓存:假的,
    网址:/ajax/ajax.asp
    数据:CMD = check_forfeits
    成功:函数(MSG){
      返回false;
    }
  });
});
 

的JavaScript错误IE抛出的权限被拒绝

如果我删除了code该位从JS文件的页面有问题的网页工作得很好,没有任何错误,所以错误就在于code表示有点相信。

::: UPDATE :::

别的东西,是有一点奇怪的是,当我刷新页面(在IE7)我没有得到任何JavaScript错误,这code似乎正常工作。所以,就好像第一次页面加载此code段错误,但在那之后它运行得很好。

::: UPDATE :::

下面是小提琴手职位这个网页IE7:

 #结果协议主机URL
1 200 HTTP 192.168.47.13:8000 /
2 304 HTTP 192.168.47.13:8000 /js/jquery-1.4.1.js
3 200 HTTP 192.168.47.13:8000 /js/index.js
4 304 HTTP 192.168.47.13:8000 /js/jquery-1.4.1.js
5 200 HTTP 192.168.47.13:8000 /js/index.js
6 304 HTTP 192.168.47.13:8000 /css/main.css
7 304 HTTP 192.168.47.13:8000 /css/grid.css
8 304 HTTP 192.168.47.13:8000 /images/banner.jpg
 

下面是小提琴手职位本页面从Firefox:

 #结果协议主机URL
1 200 HTTP 192.168.47.13:8000 /
2 304 HTTP 192.168.47.13:8000 /js/jquery-1.4.1.js
3 304 HTTP 192.168.47.13:8000 /js/index.js
4 304 HTTP 192.168.47.13:8000 /css/grid.css
5 304 HTTP 192.168.47.13:8000 /css/main.css
6 304 HTTP 192.168.47.13:8000 /images/banner.jpg
7 200 HTTP 192.168.47.13:8000 /ajax/ajax.asp
 

解决方案

我碰到了同样的问题。

我身边做了工作,解决问题。我写的code键使Ajax调用,而不使用jQuery(创建XMLHttpObject,onreadystatechange的,等等)。然后我用jQuery来解析XML。

由于某些原因,jQuery的AJAX不会与IE7的正常工作。

您并没有真正得到一个错误,在IE7,但如果你再调试它,你会看到,服务器永远不会击中或code永远不会到达成功的块。

Can anyone enlighten me as to why the following code won't work in IE7 but it works just fine in Chrome/Firefox?

$(document).ready(function(){
  $.ajax({
    type: "POST",
    dataType: "text",
    cache: false,
    url: "/ajax/ajax.asp",
    data: "cmd=check_forfeits",
    success: function(msg) {
      return false;
    }
  });
});

The javascript error IE throws out is 'Permission Denied'

If I remove that bit of code from the JS file for the page in question the page works just fine, no errors, so the error lies in that bit of code I believe.

:::UPDATE:::

Something else that is a little strange is that when I refresh the page (in IE7) I get no javascript errors and this code seems to work correctly. So it's as if the first time the page loads this code snippet errors but after that it runs just fine.

:::UPDATE:::

Here are the fiddler posts for this page from IE7:

#   Result   Protocol   Host                 URL
1   200      HTTP       192.168.47.13:8000   /
2   304      HTTP       192.168.47.13:8000   /js/jquery-1.4.1.js
3   200      HTTP       192.168.47.13:8000   /js/index.js
4   304      HTTP       192.168.47.13:8000   /js/jquery-1.4.1.js
5   200      HTTP       192.168.47.13:8000   /js/index.js
6   304      HTTP       192.168.47.13:8000   /css/main.css
7   304      HTTP       192.168.47.13:8000   /css/grid.css
8   304      HTTP       192.168.47.13:8000   /images/banner.jpg

Here are the fiddler posts for this page from Firefox:

#   Result   Protocol   Host                 URL
1   200      HTTP       192.168.47.13:8000   /
2   304      HTTP       192.168.47.13:8000   /js/jquery-1.4.1.js
3   304      HTTP       192.168.47.13:8000   /js/index.js
4   304      HTTP       192.168.47.13:8000   /css/grid.css
5   304      HTTP       192.168.47.13:8000   /css/main.css
6   304      HTTP       192.168.47.13:8000   /images/banner.jpg
7   200      HTTP       192.168.47.13:8000   /ajax/ajax.asp

解决方案

I ran into the same issue.

I did a work around to resolve the issue. I wrote the code to make the ajax call without using jQuery (created XMLHttpObject, onreadystatechange, etc). Then I used jQuery to parse the XML.

For some reason the jQuery's ajax doesn't work well with IE7.

You don't really get an error in IE7 but if you debug it then you'll see that the server is never hit and or code never reaches the success block.

这篇关于在IE7 jQuery的AJAX的问题(可能还有其他版本一样)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆