Ajax响应包含的内容超出预期

Ajax响应包含的内容超出预期,ajax,request,response,Ajax,Request,Response,文件结构 js/scripts.js library/libary.php modules/page.php 模数/404.php index.php 文件说明 php查看url的路径部分,并需要该文件。因此www.test.com/page需要modules/page.php。一些代码: $file = (DIR . 'modules/'.$action.'.php'); if(!file_exists($file)) { $file = DIR . 'modules/404.php'

文件结构

js/scripts.js

library/libary.php

modules/page.php

模数/404.php

index.php

文件说明

php查看url的路径部分,并需要该文件。因此www.test.com/page需要modules/page.php。一些代码:

$file = (DIR . 'modules/'.$action.'.php');
if(!file_exists($file))
{
    $file = DIR . 'modules/404.php';
}

//Get file
require($file);
php的正文如下所示:

<input type='submit' value='getTime' onClick='getTime()' />
function updateStatus()
   {

if (window.XMLHttpRequest) {
    xmlhttp=new XMLHttpRequest();
} else {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
    document.getElementById("content").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("POST","library/library.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("status=page");
    }
return time();
库文件包含如下内容:

<input type='submit' value='getTime' onClick='getTime()' />
function updateStatus()
   {

if (window.XMLHttpRequest) {
    xmlhttp=new XMLHttpRequest();
} else {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
    if (xmlhttp.readyState==4 && xmlhttp.status==200) {
    document.getElementById("content").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("POST","library/library.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send("status=page");
    }
return time();
问题

问题在于reponseText不仅包含时间,它还包含404.php页面。这是因为我的index.php。他查找modules/library.php,但它不存在(不在modules目录中)

所以我的问题是,ajax请求和响应的方式是什么?如何在不将library.php放入modules目录的情况下解决这个问题

我真正的问题有点复杂,但它的根源与我在这里描述的问题相同。因此,争取时间不是我的问题,只是为了说明我的问题