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);  
     }  
}); 
相关推荐
智航GIS12 小时前
10.5 PyQuery:jQuery 风格的 Python HTML 解析库
python·html·jquery
木土雨成小小测试员14 小时前
Python测试开发之前端二
javascript·python·jquery
满栀58517 小时前
基于 jQuery 实现商品列表增删改查与数据统计
前端·javascript·jquery
LongtengGensSupreme4 天前
开放所有跨域 ----前端和后端
前端·后端·ajax·vue·api·jquery
狂龙骄子8 天前
jQuery表单验证插件全攻略
前端·javascript·jquery·jquery表单验证
止水编程 water_proof12 天前
JQuery 基础
前端·javascript·jquery
搬砖的阿wei13 天前
JavaScript 请求数据的四种方法:Ajax、jQuery 、Fetch和 Axios
javascript·ajax·axios·jquery
假装我不帅14 天前
jquery.nicescroll使用
前端·javascript·jquery
一只小鸟儿15 天前
门户短信发送验证码及验证功能
前端·javascript·jquery
Han.miracle18 天前
JQuery 基础与综合案例实践
jquery·js