Home  >  Article  >  Backend Development  >  javascript - Ajax jquery load method cannot read information in php

javascript - Ajax jquery load method cannot read information in php

WBOY
WBOYOriginal
2016-08-04 09:19:111163browse

I am using appserv to build a server. Is there something wrong with the server? You can use the load method to read .html files but not .php. Attached is the code:

<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src='http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js'></script>
    <script>
        $(function (){
            $('#send').click(function() {
                $('#resText').load('demo.php');
            });
        })
    </script>
</head>
<body>
    <button id="send">点我点我点我</button>
    <div id="resText"></div>
</body>
</html>

</code>

This is the php code

<code><?php
    echo "dsjaflkasdj";
?>
</code>

I want to ask if it is a server problem and how to fix it

Reply content:

I am using appserv to build a server. Is there something wrong with the server? You can use the load method to read .html files but not .php. Attached is the code:

<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src='http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js'></script>
    <script>
        $(function (){
            $('#send').click(function() {
                $('#resText').load('demo.php');
            });
        })
    </script>
</head>
<body>
    <button id="send">点我点我点我</button>
    <div id="resText"></div>
</body>
</html>

</code>

This is the php code
<code><?php
    echo "dsjaflkasdj";
?>
</code>

I want to ask if it is a server problem and how to fix it

You can directly access demo.php on the server to see if there is any output

It may be that the path is wrong. Check the console to see if there is a 404 error


Are you sure php is started?
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn