码迷,mamicode.com
首页 > Web开发 > 详细

ajax用FormData方式提交

时间:2018-11-09 16:14:36      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:$.ajax   query   form   fun   new   table   lan   ble   nbsp   

<!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方式提交

标签:$.ajax   query   form   fun   new   table   lan   ble   nbsp   

原文地址:https://www.cnblogs.com/yingyong/p/9934895.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!