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条)

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法