select表单序列化serialize()出现问题

news/2024/7/11 1:04:14 标签: select, 表单, jQuery, 序列化

今天在序列化select时,遇到了一个问题
HTML:

    <input name="id" type="text"/>
    <select class="form-control" id="placeSelect" name="place">
        <option  value="1">1</option>
        <option  value="2">2</option>
        <option  value="3">3</option>
    </select>

原来的做法:

    alert($('select>option:selected').serialize())//''
    alert(typeof 'select>option:selected').serialize();//string

之后尝试了这种,就好了:

    alert($('select').serialize());//place=1
    alert(typeof $('select').serialize());//string

同理:

alert($('input,select>option:selected').serializeArray());//[object Object]
    alert(JSON.stringify($('input,select>option:selected').serializeArray()));//[{"name":"id","value":""}]


alert($('input,select').serializeArray());//[object Object],[object Object]
    alert(JSON.stringify($('input,select').serializeArray()));//[{"name":"id","value":""},{"name":"place","value":"1"}]

http://www.niftyadmin.cn/n/764393.html

相关文章

class h5 点击后样式变化_h5制作软件,推荐婚礼邀请函制作h5模板平台

点击上方蓝字获取h5制作平台&#xff0c;推荐精美大气h5模板样式随着网络互联网的发展&#xff0c;现在很多群众都想制作属于自己的h5软件小工具了。制作好后&#xff0c;还可以转发给好友&#xff0c;以及上传朋友圈展示呢&#xff0c;但很多人对h5软件还不了解&#xff0c;也…

一键分享工具share.js

今天做网站时&#xff0c;要用到一键分享工具&#xff0c;在网上搜了下&#xff0c;尝试了下&#xff1a; 首先网站中引入一下文件&#xff1a; <!-- css & js --> <link href"dist/css/share.min.css"> <script src"dist/js/share.min.j…

python __init__ __new___详解Python中的__init__和__new__

一、__init__ 方法是什么&#xff1f;使用Python写过面向对象的代码的同学&#xff0c;可能对 __init__ 方法已经非常熟悉了&#xff0c;__init__ 方法通常用在初始化一个类实例的时候。例如&#xff1a;# -*- coding: utf-8 -*-class Person(object):"""Silly …

uc扩展中心打不开_纳米中心段鹏飞团队圆偏振发光材料性能的提升及应用取得新进展...

近些年,具有圆偏振发光(CPL)特性的光学材料由于其在各个领域的巨大潜力而获得广泛关注&#xff0c;具有较高发光不对称因子 (glum)是实现其有效应用的关键。目前大多数报道的光学材料所得到的glum值普遍较低&#xff0c;而且圆偏振发光区域大都位于可见光区&#xff0c;相对较低…

javascript模块化编程的运用

今天又一次学习了阮一峰&#xff1a;Javascript模块化编程&#xff0c;然后用学到的require.js的用法对之前所做的考试系统的nlineLib_practice页面作了进一步的优化&#xff0c;如下&#xff1a; 删掉了onlineLi_practice.js原有的常见通用函数引入required.js&#xff1a; &…

Base64编码小图标

首先什么使Base编码呢&#xff1f; Base64是网络上最常见的用于传输8Bit字节码的编码方式之一&#xff0c;Base64就是一种基于64个可打印字符来表示二进制数据的方法。 图片的Base64编码就是用二进制字符串表示的图片&#xff0c; 如&#xff1a; 的Base64编码为&#xff1…

时间间隔python_关于一个日期时间间隔计算相关的算法(Python)

先給出我的答案&#xff1a;def findmax(timestrs, timeframe):fmt "%Y-%m-%d %H:%M:%S"times [datetime.strptime(timestr, fmt) for timestr in timestrs]frame timedelta(secondstimeframe)window dict(bidx0, eidx0)maxwindow dict(bidx0, eidx0)# searchfo…

阿里测试——生成一个CSS选择器

题目&#xff1a; 我的解法&#xff1a; <!DOCTYPE html> <html lang"en"> <head<meta charset"UTF-8"><meta name"viewport" content"widthdevice-width, initial-scale1.0"><meta http-equiv&q…