form表单提交数据

html:

<!-- 表单数据-->
<div id="">
   <form id="thenform1">
       <input type="hidden" name="page" value="1" />
   </form>
</div>

js:

data = $("#thenform1").serializeArray(); //获取所有form表单条件
$.ajax({
 url:url,
 type: "get",
 //这里是重点
 xhrFields: { //允许添加cookie
   withCredentials: true
 },
 dataType: "json",
 data:data,
 success:function(res){},
   error:function(err){console.log(err)}
})

  

 

posted on 2021-04-16 17:00  前端LHR  阅读(131)  评论(0编辑  收藏  举报

导航