相关疑难解决方法(0)

IE 11的奇怪的AJAX错误

我目前正在开发一个纯HTML和JavaScript驱动的Web应用程序,它使用CORS来使用远程Web服务,但目前在使用IE 11进行GET请求时遇到问题.有趣的是,我们已经在IE8/9/10中运行良好而不是11.

问题是IE 11似乎超时而不是等待服务器的响应.ajax调用很简单:

$.ajax(url, {
    dataType: 'json',
    complete: complete,
    type: 'GET',
    global: true,
    success: success,
    crossDomain: true,
    xhrFields: {
        withCredentials: true
    }
});
Run Code Online (Sandbox Code Playgroud)

在网络选项卡和使用Fiddler我可以看到IE甚至从未发送请求.

有没有人有任何想法吗?

编辑:我忘了提到我已经尝试过缓存:false.我还发现了一些非常奇怪的事情,如果我将开发工具中的文档模式从Edge切换到9然后再次调用,即使在我清除IE并重新启动它之后,无论缓存是真还是假,调用都会有效.非常离奇.:\

javascript ajax jquery internet-explorer

24
推荐指数
2
解决办法
4万
查看次数

XDomainRequest与XMLHTTPRequest

我们正在使用PixiJS创建一个应用程序,其中包含一个动态json加载器.

它使用以下内容加载.json文件:

if(window.XDomainRequest)
{
    this.ajaxRequest = new window.XDomainRequest();
}
else if (window.XMLHttpRequest)
{
    this.ajaxRequest = new window.XMLHttpRequest();
}
else
{
    this.ajaxRequest = new window.ActiveXObject('Microsoft.XMLHTTP');
}
Run Code Online (Sandbox Code Playgroud)

除了Windows手机和IE之外,这似乎无处不在.但是,如果我将XMLHttpRequest与XDomainRequest交换,它可以正常工作.

最后,有人可以解释XDomainRequest和XMLHTTPRequest之间的区别吗?哪一个优先于另一个?

javascript ajax internet-explorer windows-phone pixi.js

13
推荐指数
1
解决办法
1万
查看次数

获取jQuery UI主题列表 - 来自URL(同源策略)

有谁知道从http://jquery-ui.googlecode.com/svn/tags/1.8.23/themes/获取jQuery主题列表的方法?

我正在使用主题滚动创建简单的网页,用户可以动态切换主题.

工作小提琴 - 单击右上角的主题并选择一个新主题.

现在列表硬编码如下,

<div id="theme-list">    
   <ul>
      <li class="themes-el ui-state-highlight" data-theme="cupertino">cupertino</li>
      <li class="themes-el" data-theme="hot-sneaks">hot-sneaks</li>
      <li class="themes-el" data-theme="smoothness">smoothness</li>
      <li class="themes-el" data-theme="pepper-grinder">pepper-grinder</li>
      <li class="themes-el" data-theme="ui-lightness">ui-lightness</li>
      <li class="themes-el" data-theme="ui-darkness">ui-darkness</li>
      <!-- and more -->
   </ul>    
</div>
Run Code Online (Sandbox Code Playgroud)

有没有办法从URL http://jquery-ui.googlecode.com/svn/tags/1.8.23/themes/获取这个主题列表?(crossDomain:http://www.w3.org/TR/cors/#access-control-allow-origin-response-hea)

尝试,但失败的代码如下..

$.ajax({
    url: 'http://jquery-ui.googlecode.com/svn/tags/1.8.23/themes/',
    dataType: 'text',
    beforeSend: function ( xhr ) {
        xhr.setRequestHeader("Access-Control-Allow-Origin", 'http://jquery-ui.googlecode.com');
        xhr.setRequestHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
    },
    crossDomain: true,
    success: function (data) {
        alert(data);
    }, 
    error: function (jqXHR, textStatus, errorThrown) {
        alert(errorThrown + ' ' …
Run Code Online (Sandbox Code Playgroud)

javascript jquery cross-domain same-origin-policy

7
推荐指数
2
解决办法
2036
查看次数

如何在IE CORS中发送POST数据(使用XDomainRequest)

我一直在寻找一个简单的例子,说明如何在IE中的跨域请求中发送POST数据(使用XDomainRequest对象).

我已经能够发出简单的POST请求,但无法向其添加POST数据.

任何帮助表示赞赏,谢谢!

javascript jquery cors

5
推荐指数
1
解决办法
1万
查看次数

来自Node.JS(使用快速)服务器的跨域jQuery.getJSON在Internet Explorer中不起作用

这是一个烦人的问题,我不认为只有IE才有这个问题.基本上我有一个Node.js服务器,我从中进行跨域调用以获取一些JSON数据以供显示.

这需要是一个JSONP调用,我在URL中给出一个回调.我不确定的是,怎么做?

所以网站(domainA.com)有一个带有这样的JS脚本的HTML页面(在Firefox 3中都可以正常工作):

<script type="text/javascript">
    var jsonName = 'ABC'
    var url = 'http://domainB.com:8080/stream/aires/' //The JSON data to get
    jQuery.getJSON(url+jsonName, function(json){                
       // parse the JSON data
       var data = [], header, comment = /^#/, x;                    
       jQuery.each(json.RESULT.ROWS,function(i,tweet){ ..... }
    }
    ......
</script>
Run Code Online (Sandbox Code Playgroud)

现在我的Node.js服务器非常简单(我正在使用express):

var app = require('express').createServer();
var express = require('express');
app.listen(3000);

app.get('/stream/aires/:id', function(req, res){
  request('http://'+options.host+':'+options.port+options.path, function (error, response, body) {
      if (!error && response.statusCode == 200) {
          console.log(body); // Print the google web page.
        res.writeHead(200, {
             'Content-Type': 'application/json',
               'Cache-Control': 'no-cache', …
Run Code Online (Sandbox Code Playgroud)

javascript jquery internet-explorer cross-domain node.js

4
推荐指数
1
解决办法
8560
查看次数

Ajax调用在IE8中无效

我正在阅读有关此内容的几篇帖子,并对我的代码进行了一些更改,但没有运气.

任何人都可以看看这个,看看这里发生了什么?或者也许是另一种方式来做我需要的事情(使用ziptastic检索城市,邮政编码状态)

代码在Chrome(http://jsfiddle.net/7VtHc/117/)中正常工作

HTML

<asp:TextBox ID="txtZipCode" runat="server"></asp:TextBox>        
<asp:TextBox ID="txtCity" runat="server"></asp:TextBox> 
<asp:TextBox ID="txtState" runat="server"></asp:TextBox> 
Run Code Online (Sandbox Code Playgroud)

脚本

<script src="http://code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>

<script type="text/javascript">
    $(function () {
        $("input[id$='txtZipCode']").keyup(function () {
            var el = $(this);

            if (el.val().length === 5) {
                $.ajax({
                    url: "http://zip.getziptastic.com/v2/US/" + el.val(),
                    cache: false,
                    dataType: "json",
                    type: "GET",
                    success: function (result, success) {
                        $("input[id$='txtCity']").val(result.city);
                        $("input[id$='txtState']").val(result.state);
                    }
                });
            }
        });
    });
</script>
Run Code Online (Sandbox Code Playgroud)

谢谢,

javascript asp.net ajax jquery internet-explorer-8

4
推荐指数
2
解决办法
2万
查看次数

jQuery跨域请求仍然在IE中失败,但使用jsonp

我的Ajax跨域请求在IE 9中失败,并且"拒绝访问".我已经阅读了几篇关于这个主题的帖子,AFAIK应该可以使用.

  1. IE9和jQuery 1.8.1
  2. 通话async,jsonp并且crossdomain,cachefalse.这些是我找到的先决条件.
  3. 适用于最新的Firefox和Chrome.
  4. jQuery.support.cors 是真的
  5. 甚至设置响应头:Access-Control-Allow-Origin:*(SO)
  6. 返回的JSON代码也是正确的,使用了一个检查器(另见3.)

那么为什么这会因拒绝访问而失败?任何的想法?可能是因为我的代码是从"JavaScript"库中调用的,而不是<script></script>页面上的标签吗?

我错过了什么?

    // The code is part of an object's method (prototype)
    // code resides in a library "Mylib.js"

    $.ajax({
        type: 'GET',
        url: url,
        cache: false,
        async: true,
        crossdomain: true, // typo, crossDomain, see my answer below
        datatype: "jsonp", // dataType
        success: function (data, status) {
            if (status == "success" && !Object.isNullOrUndefined(data)) …
Run Code Online (Sandbox Code Playgroud)

javascript jquery cross-domain internet-explorer-9

2
推荐指数
1
解决办法
2万
查看次数