Hi,
I joined this group today in the hope that I will get help with one API issue I am having now. I am trying to get the number of user edits through an AJAX call. I have tested this script in English Wikipedia and Malayalam Wikipedia and it works there in all browsers. But this script is not working in *Wikipedia Commons*.
Pasting my script below. Any help with this is appreciated.
/***********************************************************************************************************/ *function* liveEditCounter(username) { *var* xhr; *try* { xhr = *new* XMLHttpRequest(); } *catch*(e) { xhr = *new* ActiveXObject("Microsoft.XMLHTTP"); }
xhr.onreadystatechange = *function*() { *if*(xhr.readyState == 4) { *if*(xhr.status == 200 || xhr.status == 0) { *var* jsonOutput = *eval*('(' + xhr.responseText + ')'); document.getElementById("firstHeading").innerHTML = document.getElementById( "firstHeading").innerHTML + " (Edits: " + jsonOutput.query.users[0]. editcount + ")"; } } };
xhr.open('GET', " http://commons.wikipedia.org/w/api.php?action=query&list=users&ususe... username+"&usprop=editcount&format=json", *true*); xhr.send(*null*); } /***********************************************************************************************************/
The issue here is that xhr.responseText is returning me a blank value.
Thanks for the help in advance. - Sreejith K.
2011/1/28 Sreejith K. sreejithk2000@gmail.com:
xhr.open('GET', "http://commons.wikipedia.org/w/api.php?action=query&list=users&ususe...", true);
It's commons.wikiMedia.org , not commons.wikiPedia.org
Roan Kattouw (Catrope)
It is working like a charm now. Thank you Roan.
The mistake was too silly :)
- Sreejith
On Sat, Jan 29, 2011 at 12:56 AM, Roan Kattouw roan.kattouw@gmail.comwrote:
2011/1/28 Sreejith K. sreejithk2000@gmail.com:
xhr.open('GET', "http://commons.wikipedia.org/w/api.php?action=query&list=users&ususe...
"+username+"&usprop=editcount&format=json",
true);
It's commons.wikiMedia.org , not commons.wikiPedia.org
Roan Kattouw (Catrope)
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
mediawiki-api@lists.wikimedia.org