2015-10-09 143 views
3

我在我的mybb論壇中遇到錯誤。我使用了一個插件進行高級統計。但我在控制檯中發現錯誤「Uncaught ReferenceError:Ajax沒有定義」所以這就是爲什麼我的網站不會從最上面加載最新帖子。未捕獲ReferenceError:未定義Ajax

網站:http://satfriends.net/index.php

這裏是我的代碼

<!-- start: changuondyu_stats_script --> 
 
\t <script language="JavaScript" type="text/javascript"> 
 
\t \t var fcmenu; 
 
var listtab = new Array(); 
 
listtab[0] = "allforum"; 
 
listtab[1] = "inforum&listforumid=8"; 
 
listtab[2] = "inforum&listforumid=21,15,7"; 
 
listtab[3] = "inforum&listforumid=14"; 
 

 

 
function cswitch(taborder) 
 
{ 
 
fcmenu = listtab[taborder]; 
 
document.getElementById('ct'+taborder).className = 'thead'; 
 
for (i = 0; i <= 3; i++) 
 
{ 
 
if (i != taborder) 
 
    { 
 
    document.getElementById('ct'+i).className = 'tcat'; 
 
    } 
 
} 
 
changstats_post(); 
 
} 
 

 
function hshowpost(request) 
 
{ 
 
    if (request.readyState == 4 && request.status == 200) 
 
\t { 
 
\t document.getElementById('chang_latestposts').innerHTML = request.responseText; 
 
\t document.getElementById('cprogress_post').style.display="none"; 
 
\t } 
 
} 
 
function hshowtop_user(request) 
 
{ 
 
    if (request.readyState == 4 && request.status == 200) 
 
\t { 
 
\t document.getElementById('chang_top_user').innerHTML = request.responseText; 
 
\t document.getElementById('cprogress_top').style.display="none"; 
 
\t } 
 
} 
 
function hshowtop_forum(request) 
 
{ 
 
    if (request.readyState == 4 && request.status == 200) 
 
\t { 
 
\t document.getElementById('chang_top_forum').innerHTML = request.responseText; 
 
\t document.getElementById('cprogress_top').style.display="none"; 
 
\t } 
 
} 
 

 

 
function changstats_post() 
 
{ 
 
\t document.getElementById('cprogress_post').style.display="inline"; 
 
\t fcresult = document.getmenu.choosekq.value; 
 
\t new Ajax.Request('xmlhttp.php?do='+fcmenu+'&result='+fcresult, {method: 'GET', postBody: null, onComplete: function(request) { hshowpost(request); }}); 
 
} 
 
function changstats_top_user() 
 
{ 
 
\t document.getElementById('cprogress_top').style.display="inline"; 
 
\t fcmenu_top_user = document.getmenu.choosetop_user.value; 
 
\t fcresult = document.getmenu.choosekq.value; 
 
\t new Ajax.Request('xmlhttp.php?do='+fcmenu_top_user+'&result='+fcresult, {method: 'GET', postBody: null, onComplete: function(request) { hshowtop_user(request); }}); 
 
} 
 
function changstats_top_forum() 
 
{ 
 
\t document.getElementById('cprogress_top').style.display="inline"; 
 
\t fcmenu_top_forum = document.getmenu.choosetop_forum.value; 
 
\t fcresult = document.getmenu.choosekq.value; 
 
\t new Ajax.Request('xmlhttp.php?do='+fcmenu_top_forum+'&result='+fcresult, {method: 'GET', postBody: null, onComplete: function(request) { hshowtop_forum(request); }}); 
 
} 
 

 
cswitch(0); 
 
changstats_top_user(); 
 
changstats_top_forum(); 
 

 

 
</script> 
 
<!-- end: changuondyu_stats_script -->

得到E爲一個解決方案,我怎麼能解決這個問題。

感謝

+0

那麼,它找不到'Ajax'對象的定義。你確定這個頁面中包含對象被定義的腳本嗎? – NaijaProgrammer

+0

[ajax error:Uncaught ReferenceError:Ajax未定義]的可能重複(http://stackoverflow.com/questions/16335285/ajax-error-uncaught-referenceerror-ajax-is-not-defined) – rogerdpack

回答

2

你必須包括參考其中包括該方法Ajax.Request的API。在你的情況下,它似乎是Prototype庫。

包含在HTML頁面頂部的庫:

<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.3.0/prototype.js"></script> 
相關問題