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);  
     }  
}); 
相关推荐
shenmu843 天前
gitee第三方登录获取openid | python+Django |已跑通
python·gitee·jquery
aklry3 天前
mini jquery
jquery
我最厉害。,。4 天前
JS 应用&WebPack 打包器&第三方库 JQuery&安装使用&安全检测
javascript·webpack·jquery
程序员buddha17 天前
ThinkPHP8.0+MySQL8.0搭建简单实用电子证书查询系统
javascript·css·mysql·php·layui·jquery·html5
几度泥的菜花20 天前
使用jQuery实现动态下划线效果的导航栏
前端·javascript·jquery
Enti7c1 个月前
什么是 jQuery
前端·javascript·jquery
Dontla1 个月前
jQuery介绍(快速、简洁JavaScript库,诞生于2006年,主要目标是简化HTML文档操作、事件处理、动画和Ajax交互)
javascript·html·jquery
ThomasChan1232 个月前
Typesrcipt泛型约束详细解读
前端·javascript·vue.js·react.js·typescript·vue·jquery
我头发乱了伢2 个月前
jQuery小游戏
前端·javascript·jquery