3

I got an error in my mybb forum. I used a plugins for advance stats. But i got an error in console about "Uncaught ReferenceError: Ajax is not defined" So that's why my website not loading latest post from top.

Website: http://satfriends.net/index.php

Here is my code

<!-- start: changuondyu_stats_script -->
 <script language="JavaScript" type="text/javascript">
  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)
 {
 document.getElementById('chang_latestposts').innerHTML = request.responseText;
 document.getElementById('cprogress_post').style.display="none";
 }
}
function hshowtop_user(request)
{
  if (request.readyState == 4 && request.status == 200)
 {
 document.getElementById('chang_top_user').innerHTML = request.responseText;
 document.getElementById('cprogress_top').style.display="none";
 }
}
function hshowtop_forum(request)
{
  if (request.readyState == 4 && request.status == 200)
 {
 document.getElementById('chang_top_forum').innerHTML = request.responseText;
 document.getElementById('cprogress_top').style.display="none";
 }
}


function changstats_post()
{
 document.getElementById('cprogress_post').style.display="inline";
 fcresult = document.getmenu.choosekq.value;
 new Ajax.Request('xmlhttp.php?do='+fcmenu+'&result='+fcresult, {method: 'GET', postBody: null, onComplete: function(request) { hshowpost(request); }});
}
function changstats_top_user()
{
 document.getElementById('cprogress_top').style.display="inline";
 fcmenu_top_user = document.getmenu.choosetop_user.value;
 fcresult = document.getmenu.choosekq.value;
 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()
{
 document.getElementById('cprogress_top').style.display="inline";
 fcmenu_top_forum = document.getmenu.choosetop_forum.value;
 fcresult = document.getmenu.choosekq.value;
 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 -->

Give e a solution for that, how can i fix it.

Thanks

jone hans
  • 51
  • 1
  • 1
  • 7
  • Well, it can't find the definition of the `Ajax` object. Are you sure the script where the object is supposedly defined is included in this page? – NaijaProgrammer Oct 09 '15 at 11:29
  • Possible duplicate of [ajax error: Uncaught ReferenceError: Ajax is not defined](http://stackoverflow.com/questions/16335285/ajax-error-uncaught-referenceerror-ajax-is-not-defined) – rogerdpack Mar 14 '17 at 23:15

1 Answers1

2

You have to include the reference to the api where the method Ajax.Request is included. In your case it seems that is Prototype library.

Include the library at the top of your html page:

<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.3.0/prototype.js"></script>
anmarti
  • 5,045
  • 10
  • 55
  • 96