我在 jquery 和 ajax 中编写了一段代码,在 Safari、FF 和 IE8 中运行良好,但在 IE6 中无法运行。
他可以编辑 5 组表单,这不应该显示,但只有第一个作品,ajax 在 IE6 和 IE7 中也不起作用。
scintillation 只放了 2,但是是 5 你怎么能看到下面的链接。
$(document).ready(function(){
var n=1;
$forms = $('#MemberCont'+n+' form');
$('#MemberCont'+n+' #toogle').hide();
$('#MemberCont'+n+' #hide').hide();
$('#MemberCont'+n+' a').bind('click', function(){
switch(this.id){
case 'c':
$('#MemberCont'+n+' #change').hide();
$('#MemberCont'+n+' #phone').hide();
$('#MemberCont'+n+' #hide').show();
$('#MemberCont'+n+' #toogle').show();
return false;
break;
case 'd':
$('#MemberCont'+n+' #change').show();
$('#MemberCont'+n+' #phone').show();
$('#MemberCont'+n+' #hide').hide();
$('#MemberCont'+n+' #toogle').hide();
return false;
break;
}
})
$forms.bind('submit', function(){
var $button = $('#MemberCont'+n+' button',this).attr('disabled',true);
var params = $(this.elements).serialize();
var self = this;
$.ajax({
type: 'POST',
url: this.action,
data: params,
beforeSend: function(){
$('#MemberCont'+n+' #phone').show();
$('#MemberCont'+n+' #hide').hide();
$('#MemberCont'+n+' #phone').html("Loading...");
},
success: function(txt){
$('#MemberCont'+n+' #top').show();
$('#MemberCont'+n+' #cadastro').hide ();
$('#MemberCont'+n+' #hide').hide ();
$('#MemberCont'+n+' #toogle').hide();
$('#MemberCont'+n+' #change').show();
$button.attr('disabled',false);
$('#MemberCont'+n+' #phone').html(txt);
self.reset();
},
error: function(txt){
$('#MemberCont'+n+' #phone').html(txt);
}
})
return false;
});
});
$(document).ready(function(){
var n=2;
$forms = $('#MemberCont'+n+' form');
$('#MemberCont'+n+' #toogle').hide();
$('#MemberCont'+n+' #hide').hide();
$('#MemberCont'+n+' a').bind('click', function(){
switch(this.id){
case 'c':
$('#MemberCont'+n+' #change').hide();
$('#MemberCont'+n+' #phone').hide();
$('#MemberCont'+n+' #hide').show();
$('#MemberCont'+n+' #toogle').show();
return false;
break;
case 'd':
$('#MemberCont'+n+' #change').show();
$('#MemberCont'+n+' #phone').show();
$('#MemberCont'+n+' #hide').hide();
$('#MemberCont'+n+' #toogle').hide();
return false;
break;
}
})
$forms.bind('submit', function(){
var $button = $('#MemberCont'+n+' button',this).attr('disabled',true);
var params = $(this.elements).serialize();
var self = this;
$.ajax({
type: 'POST',
url: this.action,
data: params,
beforeSend: function(){
$('#MemberCont'+n+' #phone').show();
$('#MemberCont'+n+' #hide').hide();
$('#MemberCont'+n+' #phone').html("Loading...");
},
success: function(txt){
$('#MemberCont'+n+' #top').show();
$('#MemberCont'+n+' #cadastro').hide();
$('#MemberCont'+n+' #hide').hide();
$('#MemberCont'+n+' #toogle').hide();
$('#MemberCont'+n+' #change').show();
$button.attr('disabled',false);
$('#MemberCont'+n+' #phone').html(txt);
self.reset();
},
error: function(txt){
$('#MemberCont'+n+' #phone').html(txt);
}
})
return false;
});
});
html:
<div id="MemberCont1" style="float:left; display:block; margin: 15px 30px 10px 30px; width: 563px;">
<div id="ResultTitle" style="width:217px;">Business Name</div>
<div id="MemberPhone" style="width:340px;"><div id="hide"><a href="" id="d"><img src="../img/hide_btn.gif" width="65" height="25" alt="Hide" /></a></div><div id="phone"><?php echo $result['business']; ?></div></div>
<hr class="Line" />
<div id="toogle" style="font-size:12px; color:#FFF; ">
<div id="none" style="position:relative; float:left; display:inline; padding-bottom:2px;">Change business name</div>
<form action="personal_update.php" style="clear:left; margin:0 0 10px 0;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input name="dataform" type="text" class="FormMember" id="dataform" />
<input name="id_member" type="hidden" value="<?php echo $result['id_member']; ?>" />
<input name="table" type="hidden" value="business" /></td>
<td align="right"><input name="submit" type="image" value="submit" src="../img/submit_member.gif" /></td>
</tr>
</table>
</form>
</div><!--toogle-->
<div id="change"><a href="" id="c"><img src="../img/change_btn.gif" alt="Change" width="64" height="25" align="left" /></a></div>
</div><!--/*MemberCont*/-->
<div id="MemberCont2" style="float:left; display:block; margin: 15px 30px 10px 30px; width: 563px;">
<div id="ResultTitle" style="width:217px;">Contact Name</div>
<div id="MemberPhone" style="width:340px;"><div id="hide"><a href="" id="d"><img src="../img/hide_btn.gif" width="65" height="25" alt="Hide" /></a></div><div id="phone"><?php echo $result['contact']; ?></div></div>
<hr class="Line" />
<div id="toogle" style="font-size:12px; color:#FFF; ">
<div id="none" style="position:relative; float:left; display:inline; padding-bottom:2px;">Change contact name</div>
<form action="personal_update.php" style="clear:left; margin:0 0 10px 0;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input name="dataform" type="text" class="FormMember" id="dataform" />
<input name="id_member" type="hidden" value="<?php echo $result['id_member']; ?>" />
<input name="table" type="hidden" value="contact" /></td>
<td align="right"><input name="submit" type="image" value="submit" src="../img/submit_member.gif" /></td>
</tr>
</table>
</form>
</div><!--toogle-->
<div id="change"><a href="" id="c"><img src="../img/change_btn.gif" alt="Change" width="64" height="25" align="left" /></a></div>
</div><!--/*MemberCont*/-->