0

I've some pages with URL like this: www.example.com/index.php?id={a number} and each page has the same <select> element:

<select id="foo">
    <option value="1">Page1
    <option value="2">Page2
    <option value="3">Page3
    <option value="4">Page4
</select>

and each page has a <ul> element with different li values:

<ul id="other">
    <li class="var1">some_value1_page[n]</li>
    <li class="var2">some_value2_page[n]</li>
</ul>

The Greasemonkey script takes the <select> element (in any page) and gets the 'id' page from <option> value, and then gets the <ul> values from every page and print in a div:

...
$('#foo option').each(function(){
    $(div).append( $(this).text() );
    var pageText = '';
    GM_xmlhttpRequest ({
        method: 'GET',
        url:    'index.php?id='+$(this).attr('value'),
        onload: function (responseDetails){
                    pageText = responseDetails.responseText;
                    $(pageText).find("#other li").each(function(){
                        $(div).append( $(this).text() );
                    });
                    $(div).append('<br />');
        },
        synchronous:    true
    });
});
...

if the script is running in index.php?id=1, prints:

Page1
Page2    some_value1_page[1]    some_value2_page[1]
Page3    some_value1_page[2]    some_value2_page[2]
Page4    some_value1_page[3]    some_value2_page[3]

if this is running in index.php?id=2, prints

Page1
Page2    some_value1_page[2]    some_value2_page[2]
Page3    some_value1_page[2]    some_value2_page[2]
Page4    some_value1_page[3]    some_value2_page[3]

if this is running in index.php?id=4, prints

Page1
Page2    some_value1_page[4]    some_value2_page[4]
Page3    some_value1_page[1]    some_value2_page[1]
Page4    some_value1_page[4]    some_value2_page[4]

some ideas??

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
papelucho
  • 267
  • 1
  • 3
  • 10
  • Use [Firebug's net panel](http://getfirebug.com/wiki/index.php/Net_Panel) to see the AJAX requests and responses. Are they correct? ... perhaps the code in the question is oversimplified? (The question code *appears* OK at first glance.) ... Link to the target page. – Brock Adams Jan 06 '12 at 07:04
  • there is no petition in XHR tab, is possible? Is my first time using Firebug's net panel. On the other hand, the code in the question is not simplified too much. – papelucho Jan 06 '12 at 15:24

0 Answers0