form 表单内容序列化成一个字符串

html

html 复制代码
<form id="form1" action="http://localhost:8080/xxx" method="post">    
     <p >关键字1: <input type ="text" name="keyword1" /></p>    
     <p >关键字2: <input type ="text" name="keyword2" /></p>    
     <p >关键字3: <input type ="text" name="keyword3" /></p>    
     <input type ="submit" value="提交"/>    
</form> 

form 表单数据转 json 对象

复制代码
$( '#form1').serialize()

ajax 调用时提交表单数据

js 复制代码
$.ajax({  
     url : "http://localhost:8080/xxx",  
     type : "POST",  
     data : $( '#form1').serialize(),  
     success : function(data) {  
          $( '#serverResponse').html(data);  
     },  
     error : function(data) {  
          $( '#serverResponse').html(data.status + " : " + data.statusText + " : " + data.responseText);  
     }  
}); 
相关推荐
踢球的打工仔3 天前
jquery的基本使用(5)
前端·javascript·jquery
踢球的打工仔3 天前
jquery的基本使用(3)
前端·javascript·jquery
踢球的打工仔3 天前
jquery的基本使用(2)
前端·javascript·jquery
spencer_tseng8 天前
jquery.min.js v1.12.4
javascript·jquery
码界奇点8 天前
Java Web学习 第15篇jQuery万字长文详解从入门到实战解锁前端交互新境界
java·前端·学习·jquery
A24207349308 天前
使用jQuery动态操作HTML和CSS
css·html·jquery
spencer_tseng8 天前
jquery download
javascript·jquery
weixin_3077791311 天前
Jenkins jQuery3 API 插件详解:赋能插件前端开发的利器
运维·开发语言·前端·jenkins·jquery
他是龙55113 天前
第31天:WebPack 与 jQuery 安全
安全·webpack·jquery
码界奇点17 天前
Java Web学习 第15篇jQuery从入门到精通的万字深度解析
java·前端·学习·jquery