Ajax only load div from a page by Class

Asked

Viewed 72 times

0

With ID I can guess, doing so:

$.ajax({
    url: "www.teste.com/recuperar-senha #senha",
    beforeSend: function(){
        $('.main').html("<p>Carregando...</p>");
    },
    success: function(r){
        $('.main').html(r);
    }

});

But if my file doesn’t have an ID, how do I only load a div by taking the class?

  • Your top solution should work... is giving some error?

  • It works, but my question is this: "But if in my file there is no ID, how do I load only a div taking the class?"

  • Now I think I understand

  • I may be wrong, but what you want to do, if I’m not mistaken, is done with web crawler

  • tries $('. main')[0]. html("<p>Loading...</p>");

  • jquery selector qdo has a class, normally it will return an array, pq can have several class with that name

  • if not, try to use foreach and inside put this expression q vc wants from Success

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.