Here is a code snippet that I found for rating a page. It works perfectly on my local machine, but once I upload it to the server, it throws a syntax error.
function rtgAjax(elm, ratev) {
var cerere_http = get_XmlHttp(); // get XMLHttpRequest object
// define data to be sent via POST to PHP (Array with name=value pairs)
var datasend = Array();
for (var i = 0; i < elm.length; i++) datasend[i] = 'elm[]=' + elm[i];
datasend = datasend.join('&') + '&rate=' + ratev;
cerere_http.open("POST", 'ratingfiles/ratings.php', true);
cerere_http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
cerere_http.send(datasend);
cerere_http.onreadystatechange = function() {
if (cerere_http.readyState == 4) {
eval(' var jsonitems = ' + cerere_http.responseText);
if (jsonitems) {
for (var rtgitem in jsonitems) {
var renot = jsonitems[rtgitem][2];
if (renot == 3) {
alert("You already voted \n You can rate again tomorrow");
window.location.reload(true);
} else addRtgData(rtgitem, jsonitems[rtgitem][0], jsonitems[rtgitem][1], renot);
}
}
}
}
}
This particular line of code,
eval(' var jsonitems = ' + cerere_http.responseText);
is causing a Syntax Error: Unexpected Identifier