How to filter result from another page with Jquery Load () or Get ()?

0

In an HTML I have for example:

<fieldset>
    <div>
        <h3 class="title title-line">Dados da conta</h3>
    </div>

    <div class="ch-form-row">
        <label>Usuário</label>
        <span>MEU-USUARIO</span>

        <a class="smalla" href="https://myaccount.mercadolivre.com.br/profile/changeNickName">Modificar</a>
    </div>

    <div class="ch-form-row">
        <label>E-mail</label>
        <span>[email protected]</span>
        <a class="smalla" href="https://myaccount.mercadolivre.com.br/profile/changeEmail">Modificar</a>
    </div>

    <div class="ch-form-row">
        <label>Senha</label>
        <span>**********</span>
        <a class="smalla" href="https://accountrecovery.mercadolivre.com.br/accountrecovery/changePassword">Modificar</a>
    </div>
</fieldset>

I need another page to capture the username and save it to a variable, the closest it can reach with jQuery Load() was:

$( "#id-de-teste" ).load("https://myaccount.mercadolivre.com.br/profile .ch-form-row span:first", function(data, status){
username = $('#retorno_webtracker').html();
alert(username);
    });

But I had 2 problems: The variable with the Username was also with the <span> tags, and I do not want / need this value to appear on the page, I only need it in the variable to proceed with the script routine.

With jQuery Get() I can "download" the page with the data I need, however I am not able to filter only the .ch-form-row class after the first

$.get("https://myaccount.mercadolivre.com.br/profile", function(data, status){
        //alert("Data: " + data + "\nStatus: " + status);
//username = $('span',$('.ch-form-row')).html();
filtro = data.getElementsByClassName('ch-form-row');
console.log( filtro );
    });
    
asked by anonymous 29.03.2018 / 16:58

1 answer

0

I was able to solve

$.get("https://myaccount.mercadolivre.com.br/profile", function(data, status){
        var username = $('.ch-form-row span', $(data)).html();
//todo o codigo que precisa da variavel
});
    
29.03.2018 / 19:28