使用ajax和php,ajax的返回结果为什么一直是php代码?

html代码:

<html>
    <head>
        <script src="jquery-1.3.2.js"></script>
        <script>
            $(function(){
                $("#helloBtn").click(function(){
                    $.ajax({
                        url: "test.php",
                        type: "POST",
                        success: function(res){
                                    alert(res);
                                },
                        error: function(msg){
                                    alert('error');
                                }
                    });                 
                });
            });
        </script>
    </head>

    <body>
        <button id="helloBtn">hello</button>
    </body>
</html>

php代码:

 <?php
    echo 'hello';
?>

结果:

https://img1.mukewang.com/5b557ba60001f4ec07860347.jpg

我用的是apache服务器。

潇潇雨雨
浏览 849回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP