当前位置: 首页 > Web前端 > HTML

jQuery获取form表单数据及数据提交(一)

时间:2023-03-28 16:18:46 HTML

HTML...JQuery获取表单数据JQuery获取表单数据:letjson=$('#form-box').serialize();console.log('json:',json);//输出:json:name=w3h5&type=webobject格式:letdata={};letvalue=$('#form-b??ox').serializeArray();$.each(value,function(index,item){data[item.name]=item.value;});letjson=JSON.stringify(data);console.log(json);/**输出:{"name":"asd","type":"1"}*/JQueryform表单提交$("#form-b??ox").submit();ajax异步提交$.ajax({type:"POST",url:"/post.php",data:json,dataType:"json",success:function(respMsg){}});