【问题标题】:codeigniter ajax internet explorercodeigniter ajax Internet Explorer
【发布时间】:2013-01-22 01:30:42
【问题描述】:

以下代码在 FF、opera 和 chrome 中运行良好,但在 IE 中失败

function get_modelo(modelo) {
        var selState = modelo;
        alert (selState);
        console.log(selState);
        $.ajax({    
            url: "site/ajax_call", //The url where the server req would we made.
            async: false, 
            type: "POST", //The type which you want to use: GET/POST
            data: "state="+selState, //The variables which are going.
            dataType: "HTML", //Return data type (what we expect).

            //This is the function which will be called if ajax call is successful.
            success: function(data) {
                //data is the html of the page where the request is made.
                $('#city').html(data);
            }
        })
    }

无法理解问题。

【问题讨论】:

  • 每当我遇到 IE 从 AJAX 调用返回 HTML 的问题时,我都会首先检查 HTML 是否有效。如果您忘记关闭标签或其他东西,IE 就不会那么宽容了。
  • 从你的代码中删除console.log行....此行停止执行ie中的其他行

标签: ajax internet-explorer codeigniter


【解决方案1】:

IE 中的console.log 不起作用或导致问题。

请看这里: What happened to console.log in IE8?

这里: Testing for console.log statements in IE

这里: http://paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/

或者只是谷歌搜索IE控制台日志

您的代码中的其他所有内容看起来都可以正常工作。

【讨论】:

    【解决方案2】:

    试试这个。以下将在 IE8 中工作:P

    $.ajax({    
            url: "site/ajax_call", //The url where the server req would we made.
            async: false, 
            type: "POST", //The type which you want to use: GET/POST
            data: { state: selState }, //The variables which are going.
            dataType: "html", //Return data type (what we expect).
    
            //This is the function which will be called if ajax call is successful.
            success: function(data) {
                var newDiv = $('<div></div>');
                newDiv.html(data);
                newDiv.appendTo("#city");
            }
        });
    

    【讨论】:

      猜你喜欢
      • 2012-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-15
      • 2019-08-08
      • 1970-01-01
      • 2013-08-22
      • 1970-01-01
      相关资源
      最近更新 更多