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);  
     }  
}); 
相关推荐
长城20244 天前
jQuery的$.Ajax方法分析
ajax·jquery·异步提交
♡喜欢做梦11 天前
jQuery 从入门到实践:基础语法、事件与元素操作全解析
前端·javascript·jquery
盛夏绽放16 天前
jQuery 知识点复习总览
前端·javascript·jquery
艾小码24 天前
告别jQuery:2025年原生DOM操作最佳实践
前端·javascript·jquery
合作小小程序员小小店25 天前
web网站开发,在线%射击比赛成绩管理%系统开发demo,基于html,css,jquery,python,django,model,orm,mysql数据库
python·mysql·django·jquery·html5
合作小小程序员小小店1 个月前
web安全开发,在线%射击比赛管理%系统开发demo,基于html,css,jquery,python,django,三层mysql数据库
css·mysql·django·html·jquery
Sy_planA1 个月前
介绍一下jQuery的AJAX异步请求
ajax·okhttp·jquery
鲸落落丶1 个月前
前端三大核心要素以及前后端通讯
javascript·css·html·jquery
典学长编程1 个月前
前端开发(HTML,CSS,VUE,JS)从入门到精通!第五天(jQuery函数库)
javascript·css·ajax·html·jquery
wayhome在哪1 个月前
面试造火箭 入职拧螺丝
vue.js·面试·jquery