<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>Title</title></head><body><form id="form"> ???<table> ???????<tr> ???????????<td>角色名称</td> ???????????<td><input type="text" name="role_name"></td> ???????</tr> ???????<tr> ???????????<td colspan="2" align="center"> ???????????????<button id="but" type="button">添加角色</button> ???????????</td> ???????</tr> ???</table></form></body></html><script src="/static/js/jquery.js"></script><script> ???$("#but").click(function(){ ???????var data = new FormData($("#form")[0]); ???????$.ajax({ ???????????method:"POST", ???????????data:data, ???????????url:"{:url(‘role/role_add‘)}", ???????????contentType:false, ???????????processData:false ???????}).done(function(d){ ???????????alert(d.txt); ???????}); ???});</script>
ajax用FormData方式提交
原文地址:https://www.cnblogs.com/yingyong/p/9934895.html