有了这个,我列出了我的代码,它在所有浏览器中都可以正常工作,但在 IE 中却不行。我在堆栈溢出中搜索了解决方案,但仍然无法修复。请有人帮助我吗
$(this).serialize() 在 IE 中返回空
$('Form#UserTripSearch').live('submit',function()
{
$('#NavDetailHead12').html(HugeLoading);// for loader image
alert($(this).serialize());
// 需要返回 => type=1&sortby=desc&status=paid&name=peter
var fullurl = $(this).attr('action')+'/'+$(this).serialize();
fullurl1= fullurl.replace(/&/g, "/");
fullurl2= fullurl1.replace(/=/g, ":");
// fullurl2 => sitename.com/type:1/sortby:desc/status:paid/name:peter
$.ajax({
type: "GET",
url: fullurl2,
data: "ajax=true",
success: function(data)
{
$('#NavDetailHead12').html(data);
}
});
return false;
});
HTML 代码:
<form action="sitename/search" method="get" id="UserTripSearch">
<select id="UserType" name="type">
<option value="1">User</option>
<option value="2">Member</option>
<option selected="selected" value="3">Non Member</option>
</select>
.....
<input type="text" id="UserName" placeholder="First name, Username" class="TextfiledCommon" name="name">
<div style=" float:left">
<span class="button">
<span>
<input type="submit" value="Search" id="button" name="button">
</span>
</span>
</div>
</form>
注意:我的 HTML 没问题。
jquery 在 IE 10(标准/怪异模式)上存在 bug,即 .serialize() 和 .serizlizeArray() 无法序列化表单数据。
<div id="showRole">
<form>
<input name="roleName" type="text" />
<input name="des" type="text" />
</form>
</div>
修复方法是:
var data = $("#showRole input").serialize();
使用div的id来引用表单并序列化数据。
IE只是改变了DOM树,jquery无法获取元素。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)