问题描述
这涉及到我的previous后:
http://stackoverflow.com/questions/2318696/jquery-load-method-causing-page-refresh-ajax
我改变了我的implmentation使用阿贾克斯方法,而不是.load并能正常工作在Firefox,但不是在IE7和IE6:
$('#UL&coverTabs GT;李>在')。生活(点击,函数(事件){
//查找当前标签的HREF
变量$ tabValue = $(本).attr(HREF');
$阿贾克斯({
键入:GET,
缓存:假的,
数据类型:HTML,
网址:$(本).attr(HREF),
成功:功能(数据){
$(数据).find('。benefitWrap')。每个(函数(){
变量$ benefitWrap = $(本)。html的();
$('benefitWrap。')replaceWith。($('< DIV CLASS =benefitWrap>'+ $ benefitWrap +'< / DIV>'));
});
}
});
。事件preventDefault();
});
这是我的命,因为它采取了不同年龄的走这么远。
在任何地方我错了的想法?
我不小心摸索出什么问题了。
在此变量引用链接:
变量$ tabValue = $(本).attr(HREF');
对像这样结束的哈希值:
<$p$p><$c$c>https://bupacouk.bwa.local.internal.bupa.co.uk/cash-plan-quote/quoteAction.do?getBenefitLevelDetails=getBenefitLevelDetails&productPolicyId=7850#a1这导致了AJAX摔倒在IE的博特版本。
使用下面的code:
变量$ withoutHash = $ tabValue.substr(0,$ tabValue.indexOf('#'));
Getrs摆脱它,现在它的工作原理:)
This relates to my previous post:
http://stackoverflow.com/questions/2318696/jquery-load-method-causing-page-refresh-ajax
I changed my implmentation to use the .ajax method instead of .load and it works fine in Firefox but not in IE7 or IE6:
$('ul#coverTabs > li > a').live('click', function(event) {
// Find href of current tab
var $tabValue = $(this).attr('href');
$.ajax({
type: "GET",
cache: false,
dataType: "html",
url: $(this).attr('href'),
success: function(data){
$(data).find('.benefitWrap').each(function(){
var $benefitWrap = $(this).html();
$('.benefitWrap').replaceWith($('<div class="benefitWrap">' + $benefitWrap + '</div>'));
});
}
});
event.preventDefault();
});
This is killing me as it has taken ages to get this far.
Any ideas where i am going wrong?
I accidentally worked out what the issue was.
The link referenced in this variable:
var $tabValue = $(this).attr('href');
Had a hash value on the end like so:
https://bupacouk.bwa.local.internal.bupa.co.uk/cash-plan-quote/quoteAction.do?getBenefitLevelDetails=getBenefitLevelDetails&productPolicyId=7850#a1
This cause the AJAX to fall over in bothe versions of IE.
Using the following code:
var $withoutHash = $tabValue.substr(0,$tabValue.indexOf('#'));
Getrs rid of it and it now works :)
这篇关于jQuery的阿贾克斯方法,IE7和放大器; IE6不工作,但工作正常在Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!