2008-11-19 53 views
0

我用下面的HTML页面:损坏的AJAX结果

<html> 

<head> 

<title>AJAX Example</title> 

<meta http-equiv="Content-Type" content="text/html"; charset="iso-8859-1"> 

</head> 

<script language="JavaScript" src="ajaxlib.js"></script> 

<!--define the ajax javascript library--> 

<body> 

Click this <a href="#" OnClick="GetEmployee()">link</a> to show ajax 

content (will be processed backgroundly without 

refreshing whole page)<br/> 

<!--a href=# OnClick=GetEmployee() is the javascript event on a 

link to execute javascript function (GetEmployee) inside ajaxlib.js--> 

<div id="Result">< the result will be fetched here ></div> 

<!--javascript use GetElementById function to replace the data 

backgroundly, we use <div> tag with id Result here so javascript 

can replace this value--> 

</body> 

</html> 

的JavaScript是在这里:http://www.nomorepasting.com/getpaste.php?pasteid=22046

而且PHP是在这里:http://www.nomorepasting.com/getpaste.php?pasteid=22047

的问题是,一切都似乎是合乎逻辑和有没有错误,但JavaScript似乎并没有被调用,并直接调用PHP文件给出如下结果:

那么人物会不会连贴在明显....,但大量的小盒子,像这样:

10 
01 

回答

1

对于初学者,您的getEmployee()函数应该为return false;,以防止对<a>的默认操作。小盒子的东西似乎意味着字符集不匹配。确保HTML页面和PHP页面都使用相同的字符集。我建议尝试使所有的UTF-8。

编辑:误读轻微 - 我认为这是PHP输出的字符集与数据库中的字符集不匹配。

+0

啊......为什么这么重要?我试着用iconv改变东西,但引用和东西都失踪了。 – 2008-11-19 12:38:10

0

我建议得到火狐+篡改数据附加..你就可以看到如果您的浏览器正在下载JavaScript,并查看ajax请求+数据以查看正在发生的事情。同时检查错误控制台的JavaScript错误。我会从那里开始。