douyan6871 2012-07-20 08:33
浏览 55
已采纳

Jquery Ajax没有在IE上工作

I got very strange bug on IE. I used the code below to make a ajax request to get data from database and create drop down option <option> with that data. The thing is on IE the data didn't appear properly, it's only showing first character of data, but on other browser the data are showing correctly. I tried printing out the data as well, data are correct. So I suspected either of my Jquery selection or append is wrong and tried appending outside the ajax call with some junk data and data are showing correctly but then again I put that code inside the ajax and its not showing again... I really out of clue now.. Can you guy plz help me with this? I have tested with FF, Chrome and safari they all working fine...

$.ajax({

    cache: false,
    type: "POST",
    url: "<?php echo $this->baseUrl(); ?>/rewards/getdiscounttype/",
    data: { esid: estore_id }

}).done(function( data ) {

    var obj = jQuery.parseJSON(data);
    jQuery.each(obj, function (i, app) {

        //alert(i+app['discount_type']);
        var sel = $('select[name=discount_type'+id+']');
        sel.append('<option value="'+app['id']+'">'+app['discount_type']+'</option>');

    });

});
  • 写回答

2条回答 默认 最新

  • doushi5752 2012-07-23 06:25
    关注

    Working now with JavaScript!

    $.ajax({
    
    cache: false,
    type: "POST",
    url: "<?php echo $this->baseUrl(); ?>/rewards/getdiscounttype/",
    data: { esid: estore_id } 
    
    }).done(function( data ) {
        var obj = jQuery.parseJSON(data);
    
        /* clearing options with JS since jQuery cleare the select in the DOM but enter code   herenot on screen. */
        $('select[name=discount_type'+id+']')[0].options.length = 0;
        $('select[name=discount_type'+id+']').children().remove().end().append('');
    
        jQuery.each(obj, function (i, app) {
           var sel = $('select[name=discount_type'+id+']');
           sel.append('<option value="'+app.id+'">'+app.discount_type+'</option>');
        });
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog