我使用ajax显示一个弹出窗口。这个弹出窗口包含一个窗体,这就是它的样子。铬中无法识别的jquery元素
<form id="edit_tailored_form" name="thisisthename" method="post" action="/edittailored">
<h4>Country</h4>
<p>Show only records from this country.</p>
<ul>
<li><label>Country:</label>
<select class="inpt1" name="country">
<option value="0">ALL_COUNTRIES</option>
<option value="1">United States</option>
<option value="2">France</option>
</select>
</li>
</ul>
<h4>Hashtags</h4>
<div class="clr" style="height:10px;"></div>
<p>Show only records under these hashtags.</p>
<ul>
<li><label>Hashtags:</label><input type="text" name="hashtags_select" class="hashtags_select inpt1">
<a href="javascript:void(0);" class="add_btn" id="addhash_lst">+</a>
<input type="hidden" class="cid" value="" />
<div class="hashtags_list"></div></li>
<li><label> </label>
<div class="hashtags_display">
<ul>
<!-- display here the added hashtags--->
</ul>
</div>
<input type="hidden" name="hashtags" class="hashtags_hdn" value="1,3,13">
</ul>
<div class="clr" style="height:0px;"></div>
<h4>Save and quit</h4>
Save the modification and quit.
<ul>
<li><label class="control_label"> </label><a href="javascript:void(0);" class="close_popup"> </a> <input type="button" id="edit_tailored_btn" class="btn1" value="Save" /></li>
</ul>
</form>
而在JavaScript文件,我添加了这个动作:
$('#edit_tailored_btn').live('click', function(event) {
event.preventDefault();
event.stopPropagation();
var data = $('#edit_tailored_form').serialize();
$.ajax({
url: '/edittailored',
data: data + '&ajx=2',
type: 'post',
success: function(data) {
$('#add_record_wrapper').html(data);
}
});
})
随着edit_tailored_btn形式站立 “保存” 按钮的ID。
正如你所看到的,我序列化表单以获取其输入的数据,所以我可以使用ajax(再次)发送它们。
我的问题是,序列化像不能在铬(它在Firefox中工作)。一个检查发现,它不是实际序列化哪个不起作用,但我的表单不被识别,因为alert($('#edit_tailored_form').attr('name'));
显示为空。
有什么想法?
作品在Chrome中:http://jsfiddle.net/LKZD2/ - 张贴您正在使用什么版本的jQuery的更多信息 –
? .live()从版本1.7开始被弃用,并在1.9版本中被删除。 – melancia
我正在使用1.7 ..我的项目中太多其他示例中的live工程 – SmootQ