How do i fix this JS scope in GM_xmlhttpRequest

Posted by acidzombie24 on Stack Overflow See other posts from Stack Overflow or by acidzombie24
Published on 2010-06-09T17:39:03Z Indexed on 2010/06/09 17:42 UTC
Read the original article Hit count: 359

When i run this code alert 2 shows 6 different href links. alert 3 shows the last href 6 times. How do i make it use the same object (linkdom aka thelink) as alert 2.

NOTE: This is in a greasemonkey script

    {
        var linkdom = thelink;
        alert('2' + linkdom.getAttribute("href"));
        GM_xmlhttpRequest({
            method: 'GET',
            url: href,
            onload: function(resp){
                //...
                alert('3' + linkdom.getAttribute("href"));
            }
        });
    //...
    }

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about greasemonkey