Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.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 无法更改我的ajax内容的代码_Javascript_Php_Jquery_Ajax - Fatal编程技术网

Javascript 无法更改我的ajax内容的代码

Javascript 无法更改我的ajax内容的代码,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,好的,我正在使用教程杂志的脚本。 基本上,链接的基本设置是: /page_number.php 而链接本身就是;页码 但是我不能链接除page_number.php之外的任何东西,我需要知道如何更改脚本,这样我就可以链接我网站上的任何链接而不会弄乱它 这是代码 index.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-tr

好的,我正在使用教程杂志的脚本。 基本上,链接的基本设置是:

/page_number.php

而链接本身就是;页码

但是我不能链接除page_number.php之外的任何东西,我需要知道如何更改脚本,这样我就可以链接我网站上的任何链接而不会弄乱它

这是代码

index.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
<link rel="stylesheet" type="text/css" href="demo.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script>

</head>

<body>

<a href="#page1">Page 1</a>
<a href="#page2">Page 2</a>
<a href="#page3">Page 3</a>
<a href="#page4">Page 4</a>



    <div id="pageContent">
    Hello, this is a demo for a <a href="http://tutorialzine.com/2009/09/simple-ajax-website-jquery/" target="_blank">Tutorialzine tutorial</a>. To test it, click some of the buttons above. Have a nice stay!</div>
    </div>


</body>
</html>
load_page.php

<?php

if(!$_POST['page']) die("0");

$page = (int)$_POST['page'];

if(file_exists('page_'.$page.'.php'))
echo file_get_contents('page_'.$page.'.php');

else echo 'There is no such page!';
?>


非常感谢您的帮助。

根据@epascarello的评论,您需要通过执行以下操作绑定函数,将该点链接到哈希:

// bind to <a> that have their href attribute start with #
$('ul li a[href^=#]').click(function (e) { 
    checkURL(this.hash);
});
//绑定到以href属性开头的#
$('ul li a[href^=#]')。单击(函数(e){
checkURL(this.hash);
});

你需要绑定到带有散列的链接,而不是所有链接。对不起,我对这种编码相当陌生,我该怎么做:/?
// bind to <a> that have their href attribute start with #
$('ul li a[href^=#]').click(function (e) { 
    checkURL(this.hash);
});