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);  
     }  
}); 
相关推荐
喵本喵叁肆4 天前
06-M6-部门过滤与综合研判-从问答机到研判助手
前端·javascript·jquery
এ慕ོ冬℘゜4 天前
jQuery 核心方法
前端·javascript·jquery
CarIise4 天前
事件传播、CSS动画、服务器字体与jQuery
服务器·css·jquery
马优晨5 天前
pom.xml 中 jquery webjars 依赖解释
xml·前端·jquery·jquery webjars·webjars依赖
এ慕ོ冬℘゜5 天前
前端实战:jQuery实现动态表格渲染与状态切换功能
前端·javascript·jquery
7177777 天前
Gitee 用 AI Agent 重塑 DevSecOps 全流程:从 “被调用的工具“ 到 “主动干活的队友“
人工智能·gitee·jquery
lv__pf9 天前
ajax的使用、json、jquery
ajax·json·jquery
এ慕ོ冬℘゜13 天前
使用 jQuery 动态渲染表格与状态切换
前端·javascript·jquery
এ慕ོ冬℘゜15 天前
前端实战:使用 jQuery 与 CSS3 打造动态数据表格与滑块交互
前端·css3·jquery
油丶酸萝卜别吃24 天前
jquery-ajax.js 说明文档
前端·javascript·jquery