通过 getJSON 发送 :selected from multiple selectable select 的列表
我在多重选择元素中有一个日期列表,我需要将所选日期列表发送到服务器进行处理。
jQuery 变得混乱,让我的内存和 CPU 使用率持续增加,我不明白,因为单独运行混乱部分就可以了。
HTML
<select id="my-dates" name="my-dates[]" multiple="multiple" size="5">
<option>2011-01-18</option>
<option>2011-01-20</option>
<option>2011-01-21</option>
<option>2011-01-27</option>
</select>
jQuery
$.getJSON('dates_handling.php',{
dates: $('select#my-dates').find(':selected'),
other:stuff
},function(result){
// result handling
});
data key 'dates' should contain an transmit-able array like ['2011-01-20',2011-01-27']
jQuery haywire part
$('select#my-dates').find(':selected')
I have a list of dates in a multiple select elemental, and I need to send the list of selected dates to server for handling.
The jQuery is going haywire giving me a continuous increase in both memory and cpu usage, which I dont understand as running the haywire part alone is fine.
HTML
<select id="my-dates" name="my-dates[]" multiple="multiple" size="5">
<option>2011-01-18</option>
<option>2011-01-20</option>
<option>2011-01-21</option>
<option>2011-01-27</option>
</select>
jQuery
$.getJSON('dates_handling.php',{
dates: $('select#my-dates').find(':selected'),
other:stuff
},function(result){
// result handling
});
data key 'dates' should contain an transmit-able array like ['2011-01-20',2011-01-27']
jQuery haywire part
$('select#my-dates').find(':selected')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会手动构建日期数组,因为您正在传递完整的 jQuery 对象:
I'd build the date array manually because you are passing full jQuery objects:
您还可以使用:
它返回选择为数组的值。
You can also use:
It returns the values selected as an array.