美文网首页软件开发
Ajax前后端交互

Ajax前后端交互

作者: 9979eb0cd854 | 来源:发表于2018-08-16 17:50 被阅读762次

    注意:要放到服务器上才能运行

    Ajax简单的用法:

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <body>
            <input type="button" id="btn" value="点我进行数据交互"/>
            
            
            <script src="js/jquery-1.8.3.js"></script>
            <script>
                $("#btn").click(function(){
                    $.ajax({
                        type: "post",
                        url: "data.json",
                        //success会在成功接收到返回数据后触发
                        success: function(res) {
                            console.log(res);
                            
                        }
                    })
                })
            </script>
        </body>
    </html>
    
    
    image.png

    难点:数据交互过来如何处理

    相关文章

      网友评论

      本文标题:Ajax前后端交互

      本文链接:https://www.haomeiwen.com/subject/nsmobftx.html