Javascript 我的Ajax脚本和事件对象不知何故并没有阻止加载

Javascript 我的Ajax脚本和事件对象不知何故并没有阻止加载,javascript,html,ajax,Javascript,Html,Ajax,我目前正在使用AJAX使我的网站更加动态。但不知何故,事件对象方法e.preventDefault()不会触发以阻止加载链接。我已经指定了一个要更换的容器,现在我不知道失败的原因。通过.load方法,我正在加载HTML内容,确切地说是来自HTML中另一个“容器”的内容 My index.php: <nav> <a class = "current" href="index.php">Home</a> <a href="search.htm

我目前正在使用AJAX使我的网站更加动态。但不知何故,事件对象方法e.preventDefault()不会触发以阻止加载链接。我已经指定了一个要更换的容器,现在我不知道失败的原因。通过.load方法,我正在加载HTML内容,确切地说是来自HTML中另一个“容器”的内容

My index.php:

<nav>
    <a class = "current" href="index.php">Home</a>
    <a href="search.html">Search</a>
</nav>
<div class="header">
    <header class="title">jrr scientists - Official</header>
    <img id="logo" height="100" width="160" src="Logo/dev.png">


</div>
<section id="content">
    <div id="container">
    <div class="img2">
        <img id="ish"src="img/ish.jpg">
        <img id="mit" src="img/it.png"><br>
        <img width="100" height="100" id="home" src="img/toys1.jpg">
        <img width="200" height ="100" src="img/This is CS50.gif"> <br><br> <br><br> 
        <p> This is supposed to be a small thank you to all these institutions to make </p>
        <p> education accessable worldwide, even to  non-college students. Therefore material </p>
        <p> will be pblished here to enhance the use of this education. </p>
        <p> *********************************************************************************************** </p>
        <p> *********************************************************************************************** </p>
        <p> From the Editor JRR - Jayant Raul Rao </p>

    </div>


    <div id="text">
    <p> This is the official website of jrr developer and the </p>
    <p> CS environment to make your life easier. This website</p>
    <p> will focus on programming and computer science introducing </p>
    <p> concepts, displaying offical documentations and scripts </p>
    <p> from various examples. We can actually have a look at </p>
    <p> Google Scholar pdf's and a lot of facts of cs, maths </p>
    <p> and physics undermining the determination and will to </p>
    <p> save and keep data in a way to help. This page will be </p>
    <p> empowered by different features like a search engine, </p>
    <p> CS50 lectures, Google Scholar texts and maths problems. </p>
    <p>********************************************</p>
    <p>                JRR (Jayant Raul Rao)                    </p>
    </div>



    <div id="img">
    <img  class= "img" width="200" height="120" src="img/ibm.jpg">
    <img  id = "img1" width="190" height="120" src="img/term.png"> <br>
    <img  id="xcode"width="80" height="70" src="img/xcode.png">
    </div>
</div>
</section>
<script type="text/javascript" src="JS/basis.js"></script>
<script type="text/javascript" src="JS/ajax.js"></script>
在此之后,我将加载此容器并用新容器替换旧容器:

<!DOCTYPE html>
<html>
<head>
    <title>Search</title>
</head>
<body>
<section id = "content"> 
<div id="container">
<!-- <img src="toys1.jpg" /> -->
<div id="header">
            <img class="pio"alt="CS50 Search" src="img/Unknown.gif"/>
        </div>

<form action="https://www.google.com/search" method="get">
     <input class="t" name="q" type="text"/><br/>
     <button class="u">Search</button>
</form>

</div>
</section>
<script type="text/javascript" src="JS/ajax.js"></script>
</body>
</html>

搜寻

搜寻

提前感谢您

检查firebug..一定有错误..这在很大程度上取决于您使用的浏览器,我首先尝试添加
返回false在回调结束时。我检查了Chrome Inspector,Firefoxs Firebug,目前有00个错误我在最新版本的Safari,Chrome,Firefox中尝试过,将它传输到我电脑上的另一个web服务器上,在IE上运行,但它也不起作用。你能创建一个显示实际问题的程序吗?
<!DOCTYPE html>
<html>
<head>
    <title>Search</title>
</head>
<body>
<section id = "content"> 
<div id="container">
<!-- <img src="toys1.jpg" /> -->
<div id="header">
            <img class="pio"alt="CS50 Search" src="img/Unknown.gif"/>
        </div>

<form action="https://www.google.com/search" method="get">
     <input class="t" name="q" type="text"/><br/>
     <button class="u">Search</button>
</form>

</div>
</section>
<script type="text/javascript" src="JS/ajax.js"></script>
</body>
</html>