I’m trying to make a code that automatically counts the members in a particular member group of my forum (Proboards to be exact). Member names are in tags labeled with classes of group0, group1 and so forth. So, what I did was to call all the names from the View All Members page to automatically gain a member count.
However, I found out that the View All Members page can only display a maximum of 200 names per page. Hence, if my forum was to exceed the total member count of 200, it wouldn’t be able to include the members appearing on the succeeding pages in the count.
So I’m asking, is it possible to load elements from two or more remote pages?
Btw, here’s how my code looks like:
$(document).ready(function(){
$('<div></div>').load("/index.cgi?action=members&view=all&perpage=200 a[class^='group']", function () {
$('#result1').text( $('a.group1', this).length );
$('#result2').text( $('a.group2', this).length );
});
});
You can use $.get within a loop to get multiple pages, and then store the information within those pages in a variable (each loop iteration could just add to the variable).
One change you would have to make is how you get the information parsed out of the page because $.get does not allow you to retrieve page fragments with selectors (like your “a[class^=’group’]” selector).
var counter = 1; var all_data = ""; while (counter < 5) { $.get('/index.cgi?action=members&view=all&perpage=200', function (data) { all_data += data; }); counter++; }Some Notes:
Here is the related documentation for JQuery:
$.get() – http://api.jquery.com/jQuery.get/
load() – http://api.jquery.com/load/