jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – 即接收相同的ajax响应大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个ajax搜索,在你输入时过滤.它在chrome和firefox中运行良好.但是,无论您发送什么数据,IE总是返回相同的响应.这是为什么?以下是代码

var cardSearch = $('<div>').addClass('card_search').appendTo($('body')).hide().css({'position': 'absolute','width': '350px','height': '300px','BACkground': '#D5D5D5','padding': '10px'}).append(
    $('<div>').css({'BACkground': 'whiteSmoke','padding': '5px','height': '290px','position': 'relative'}).append(
        $('<input>').css('width','250px').bind('keyup',function(E){
            $.post('http://api.redemptionconnect.com/cards/find/?a=' + Math.random(),{data: {title: $(this).val(),limit: 10,page: 1}},function(r){
                $('ul',cardSearch).empty();
                for( var i = 0; i < r.data[0].length; i++ )
                    $('ul',cardSearch).append(
                        $('<li>').append(
                            $('<a>').attr('href','javascript:void(0)').html(r.data[0][i].Card.title + ' (' + r.data[0][i].CardSet.abbreviation + ')').attr('card_id',r.data[0][i].Card.id).mou@R_419_2433@ver(function(){showCardTooltip(this);})
                        ).css({'padding': '5px','border-bottom': '1px solid #ccc'})
                    );
            },'json'); 
        }),$('<button>').html('Search').css({'width': '70px','margin-left': '10px'}),$('<hr>').css('margin-bottom',0),$('<ul>').css({
            'list-style-type': 'none','margin': 0,'padding': 0,'width': '100%'
        })
    )
);

在chrome和firefox中,输出是正确的.在IE中,无论您键入什么,输出始终都是相同的.我不确定还包括什么.您可以在http://redforum.blackfireweb.com看到它工作,然后单击“搜索卡”菜单按钮.

解决方法

当谈到AJAX请求缓存时,IE可能非常苛刻.如果你在jQuery的.ajax对象中设置cache:false,它会将自己的缓存破坏查询字符串附加到url:

$.ajax({ cache: false })

在$.post()上面添加这个并放下你自己的那个,看看是否有所作为.

大佬总结

以上是大佬教程为你收集整理的jquery – 即接收相同的ajax响应全部内容,希望文章能够帮你解决jquery – 即接收相同的ajax响应所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。