Rating Star Script with huge registered data

Place for comments, problems, questions, or any issue related to the JavaScript / PHP scripts from this site.
David
Posts:15

Rating Star Script with huge registered data

Hi Marplo
I've run into trouble with this again :(

On the demo I am testing I only have 36 games and the rating script works fine, but when I added nearly 3,000 games the script dies as in it just becomes a horizontal bar.

I had a look at everything - Removed a lot of other js that may have been a conflict - But it made no difference. And if I keep refreshing the page it sometimes works after a LOT of refreshing?

Is this a problem with Json and huge numbers because nothing changed only the number of games and it's odd that it works fine with 36 game entries but not with 2,986?

Thanks, David.

Admin Posts:805
I didn't test the script with so many entries, but I think the cause is the big size of the json file.
Not know if is on the php side or in javascript. I suppose the json file breaks and so results an invalid json format.
Try to replace this line of code (114 in ratings.js file):

Code: Select all

eval("var jsonitems = "+ cerere_http.responseText);
With this:

Code: Select all

var jsonitems = JSON.parse(cerere_http.responseText);
Anyway i'am not sure if will works, without tests and debug with those data I not know how to find the solution, and maybe this script cannot work with so huge json file.

David Posts:15
No it didn't work - But thanks for the quick response. :)

I re-tested it earlier with 80 games entries in the Db table and it was sort of working on page-refresh - and sort of not, but when I reduced the column to 40 entries it was all okay again.
maybe this script cannot work with so huge json file.
That seems to be the problem?

Now I'll have to find something else that's still written in MySql and convert it to PDO - As PDO rating-scripts are definitely in short supply.... ;)
Thanks again.

Admin Posts:805
I just tested the Rating Stars Script with 3000 inserted rows in mysql, and 225 items diplayed in web page.
And, it works fine.
The json data contains only the ratings of the items added in current page, you can have 5000 items registered in mysql, it not affect the json size passed to javascript.
The problem is not from the script. Maybe it is something from your system /server or browser. I tested with Firefox and Chrome.

David Posts:15
Viola! it is fixed. :)

After thinking about it, it appeared that the ratings were getting "Lost" in time as the pages are pretty heavy with thumbnails and other stuff and generally take somewhere close to 0.550ms to load.

So this appears to be the culprit, in the "ratings.js" file.

Code: Select all

setTimeout("getRtgsElm()", 200);
At 300 it works - So I'll set it to 500 to give it some breathing room.