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);  
     }  
}); 
相关推荐
艾小码2 天前
告别jQuery:2025年原生DOM操作最佳实践
前端·javascript·jquery
合作小小程序员小小店3 天前
web网站开发,在线%射击比赛成绩管理%系统开发demo,基于html,css,jquery,python,django,model,orm,mysql数据库
python·mysql·django·jquery·html5
合作小小程序员小小店4 天前
web安全开发,在线%射击比赛管理%系统开发demo,基于html,css,jquery,python,django,三层mysql数据库
css·mysql·django·html·jquery
Sy_planA6 天前
介绍一下jQuery的AJAX异步请求
ajax·okhttp·jquery
鲸落落丶10 天前
前端三大核心要素以及前后端通讯
javascript·css·html·jquery
典学长编程13 天前
前端开发(HTML,CSS,VUE,JS)从入门到精通!第五天(jQuery函数库)
javascript·css·ajax·html·jquery
wayhome在哪14 天前
面试造火箭 入职拧螺丝
vue.js·面试·jquery
Ynov18 天前
使用jQuery动态操作HTML和CSS
css·html·jquery
mortimer18 天前
一行代码的“失效”:从`InvalidStateError`说起
javascript·html·jquery
试图让你心动21 天前
原生input添加删除图标类似vue里面移入显示删除[jquery]
前端·vue.js·jquery