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);  
     }  
}); 
相关推荐
传人once6 天前
选择文件按钮样式如何美化
前端·html·css3·jquery·html5
传人once9 天前
网页文字滚动效果如何做
前端·css·html·jquery·html5
传人once9 天前
多图片上传预览功能如何写
前端·css·html·jquery·html5
传人12 天前
网页文字滚动效果如何做
前端·javascript·jquery
研☆香14 天前
jQuery + Swiper.js 实现动态渲染轮播图
前端·javascript·jquery
刺客码1 个月前
Layui 表格固定列行高错位问题解决方案
前端框架·layui·jquery·web
এ慕ོ冬℘゜1 个月前
前端实战:基于jQuery递归实现通用树形组织菜单(可直接复用)
前端·javascript·jquery
零域码客1 个月前
一文掌握 jQuery + Flask 全栈核心知识点(前端交互 + 后端接口 + 前后端联调)
前端·python·ajax·flask·jquery·前后端联调·web全栈
暖焰核心1 个月前
C++模板进阶——特化全解
javascript·c++·jquery
喵本喵叁肆2 个月前
06-M6-部门过滤与综合研判-从问答机到研判助手
前端·javascript·jquery