前端代码如下:后端准备这样处理:求各位大神帮忙指点一下,前端ajaxSubmit()要怎么编写传值和返回。

解决方案 »

  1.   

    $(form).ajaxSubmit({
                    dataType: 'json',
                    success: function(data){
                        alert(data.message);
                    }
                });
      

  2.   


    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
        </head>
        <title></title>
        <body>
           <form>
                Name:<input type="text" id="name">
                <input type="button"  value="提交" id="bb">
           </form>
        </body>
        <script>
                $(function(){
                    $("#bb").click(function(){
                        $.ajax({
                            url: 'b.php',
                            type: 'post',
                            dateType: 'json',
                            data: {name: $("#name").val()},
                            success: function (result) {
                                var result = jQuery.parseJSON(result);
                                alert("name:"+result.name+";"+"password:"+result.password);
                            },
                            error: function (result) {
                                alert("error");
                            }
                        });
                    });            })
        </script>
    </html>