Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/251.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jquery在通过Ajax调用另一个页面期间未运行_Javascript_Php_Jquery_Ajax - Fatal编程技术网

Javascript Jquery在通过Ajax调用另一个页面期间未运行

Javascript Jquery在通过Ajax调用另一个页面期间未运行,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我有一个索引页面,从我称之为Jquery和PHP页面的索引页面(合并在一个.PHP文件中),如果我单独运行一个.PHP文件,一切都正常运行,但如果我通过Ajax调用同一个页面,那么它就不运行了 示例代码: index.php <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>mouseover demo<

我有一个索引页面,从我称之为Jquery和PHP页面的索引页面(合并在一个.PHP文件中),如果我单独运行一个.PHP文件,一切都正常运行,但如果我通过Ajax调用同一个页面,那么它就不运行了

示例代码:

index.php

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>mouseover demo</title>
        <script src="script/javaScript.js"></script>
    </head>        
    <body>
        <a style="cursor:pointer;" onclick="addpage()">click</a>
        <div id="view"></div>
    </body>
</html>
<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>mouseover demo</title>
        <script src="http://code.jquery.com/jquery-1.10.2.js"></script>  
        <script src="script/javaScript.js"></script>
    </head>
    <body>
        <table>
            <tr>
                <td>
                    <div class="staroverout">
                        <span>move cursor to change text</span>
                    </div>
                    <br>
                    <div class="staroverout">
                        <span>move cursor to change text</span>
                    </div>
                    <br>
                    <div class="nstaroverout">
                        <span>move cursor to change text</span>
                    </div>
                </td>
            </tr>
        </table>
    </body>
</html>
one.php

<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>mouseover demo</title>
        <script src="script/javaScript.js"></script>
    </head>        
    <body>
        <a style="cursor:pointer;" onclick="addpage()">click</a>
        <div id="view"></div>
    </body>
</html>
<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>mouseover demo</title>
        <script src="http://code.jquery.com/jquery-1.10.2.js"></script>  
        <script src="script/javaScript.js"></script>
    </head>
    <body>
        <table>
            <tr>
                <td>
                    <div class="staroverout">
                        <span>move cursor to change text</span>
                    </div>
                    <br>
                    <div class="staroverout">
                        <span>move cursor to change text</span>
                    </div>
                    <br>
                    <div class="nstaroverout">
                        <span>move cursor to change text</span>
                    </div>
                </td>
            </tr>
        </table>
    </body>
</html>

鼠标悬停演示
移动光标以更改文本

移动光标以更改文本
移动光标以更改文本
如果您尝试删除one.php中的那些jquery.js怎么样

因为当您再次将jquery包含在页面“one.php”中时,它已经包含在页面中一次了,所以我再次被包含,这会导致
jquery冲突

  • 您正在使用jQuery,但忘记将其包含在
    index.php
    中:

  • one.php
    文件中删除额外的元素(
    html
    head
    script
    ):

    <table>
        <tr>
            <td>
                <div class="staroverout">
                    <span>move cursor to change text</span>
                </div>
                <br>
                <div class="staroverout">
                    <span>move cursor to change text</span>
                </div>
                <br>
                <div class="nstaroverout">
                    <span>move cursor to change text</span>
                </div>
            </td>
        </tr>
    </table>
    
    
    移动光标以更改文本
    
    移动光标以更改文本
    移动光标以更改文本
  • 如果您正在使用jQuery,那么您将使用发送Ajax请求


  • 你为什么不让事情变得更简单,在哪里使用
    one.php
    ?我看到
    change text mouseover.php
    这里有两件事需要纠正。1.为什么不使用jquery
    $.ajax()
    ,它比用于ajax调用的原始Javascript代码简单易用。2.您的php页面根本不包含任何php代码,据我所知,除非您不
    echo
    php页面中的数据,否则调用页面不会返回任何内容。
    <table>
        <tr>
            <td>
                <div class="staroverout">
                    <span>move cursor to change text</span>
                </div>
                <br>
                <div class="staroverout">
                    <span>move cursor to change text</span>
                </div>
                <br>
                <div class="nstaroverout">
                    <span>move cursor to change text</span>
                </div>
            </td>
        </tr>
    </table>