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

 

posted on 2018-11-09 14:25  英勇博客  阅读(172)  评论(0编辑  收藏  举报