<!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>