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);  
     }  
}); 
相关推荐
二月垂耳兔79813 天前
jQueryHTML与插件
前端·jquery
Enti7c18 天前
用 HTML、CSS 和 jQuery 打造多页输入框验证功能
css·html·jquery
ElasticPDF-新国产PDF编辑器18 天前
HTML && jQuery PDF Annotation plugin library free online API examples
pdf·html·jquery
Enti7c19 天前
前端表单输入框验证
前端·javascript·jquery
ElasticPDF-新国产PDF编辑器19 天前
HTML && jQuery 项目 PDF 批注插件库在线版 API 示例教程
pdf·html·jquery
Enti7c20 天前
数据一键导出为 Excel 文件
前端·javascript·excel·jquery
小旋风0123423 天前
封装可拖动弹窗(vue jquery引入到html的版本)
vue.js·html·jquery
Json_25 天前
jQuery选项卡小练习
前端·深度学习·jquery
Json_25 天前
jQuery打字机小练习
前端·深度学习·jquery
shenmu841 个月前
gitee第三方登录获取openid | python+Django |已跑通
python·gitee·jquery