jQuery serializeArray在Safari中不起作用 [英] jquery serializeArray doesn't work in Safari

查看:209
本文介绍了jQuery serializeArray在Safari中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JQuery的serializeArray方法从简单表单创建对象数组(从表单获取数据并缓存以备后用):

I'm trying to use JQuery's serializeArray method to create an array of objects from a simple form (get data from a form and cache to be use later):

<fieldset class="myFieldset">
    <div id="divContainer">         
        <div class="anotherdiv">
            <input type="text" name="testBox1" class="aclass" />
            <select name="testSel1" class="atestclass">
                <option value="car">car</option>
                    <option value="boat">boat</option>
                    <option value="plane">plane</option>
                </select>
            </input>
         </div>
     </div>
 </fieldset>
 <fieldset class="submit-wrap">
        <input type="submit" name="enter" id="enter" value="Enter" >
 </fieldset>

我在点击时调用了serializeArray:

I'm invoking the serializeArray on click:

$('#enter').click(function(){       
    var testForm = jQuery('.myFieldset').serializeArray();
    alert(testForm);
});   

这在chrome( http://jsfiddle.net/pCELZ/)中可以正常使用,但在苹果浏览器.有什么想法吗?

This works fine in chrome (http://jsfiddle.net/pCELZ/), but not in Safari. Any ideas?

///我的表单元素未禁用,并且包含名称"属性.尝试了各种HTML ... //预先感谢.

//My form elements are not disabled and I include the 'name' attribute. Tried various html... //Thanks in advance.

推荐答案

代替使用fieldset使用form:

<form class="myFieldset">
  <div id="divContainer">         
    <div class="anotherdiv">
        <input type="text" name="testBox1" class="aclass" />
        <select name="testSel1" class="atestclass">
            <option value="car">car</option>
                <option value="boat">boat</option>
                <option value="plane">plane</option>
            </select>
        </input>
     </div>
   </div>
 </form>

并在此处进行测试: 小提琴

and test it here: fiddle

这篇关于jQuery serializeArray在Safari中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆