2008-11-19 101 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錯誤。我會從那裏開始。