weixin_33744854 2014-01-30 19:01 采纳率: 0%
浏览 6

jQuery $ .ajax,$。get问题

I have a $(".clickButton").click(function() that loads a page using $.ajax and return the result to a DIV. This works perfectly in Chrome, FireFox and Safari, but not IE11.

$.ajax({
    url: "go.php?ab=1",
        success: function(data, textStatus, xhr) {
        $("#res").html(data);       
   }
});

As a quick test I tried the following and again it works in Chrome, FireFox and Safari but not IE11.

$.get('go.php?ab=1', function( jqXHR, textStatus, errorThrown )
{ alert(jqXHR); });

The date being returned is text and is either OK or ERROR. The go.php is running multiple command line scripts and depending what the variables passed depneds on what runs.

All that part is fine and it works really well in the 3 browsers, but not IE11.

When the page first loads in IE it sort of works, it appears to run the go script and return a result. But any subsequent click return instant and the go.php page isn't called. Results are displayed but they appear to be the first processes return results. It's as if the result and process have been cached.

Any ideas how to make this work in IE as it does in the others ?

  • 写回答

2条回答 默认 最新

  • weixin_33749131 2014-01-30 19:15
    关注

    I dont know if we been to the same problem, but just earlier I was trying to get the responce data from the go.php and add it into a div.

    My code goes like this.

    onClick:

    <script type="text/javascript">
        function gimmeData(){
    
                        var url = 'go.php';
                        $.ajax({
                        type: "GET",
                        url: url,
                        data:{'something':'1'},
                        success:function(results)
                        {   
                            $('#add_data').html(results);
                        }
                        });
                    }
    </script>
    

    this will give go.php?something=1 url.

    html:

    <input type="button" onclick="gimmeData();" value="clickme!" />
    <div id="add_data"></div>
    

    button click

    $('a').on('click', function(){
        var a = $(this).data('first');
        var b = $(this).data('second');
        alert(a + ":" + b);
    });
    

    html:

    <a id="button" href="#" data-first="something" data-second="something2" onclick="click();">click me</a>
    

    using data() function. see http://api.jquery.com/data/

    or you can do $(this).attr("data-value") to get the value of a data-attribute

    JSFiddle sample.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答