Page 1 of 1

Use jquery get specific element from remote page

Posted: Wed Aug 27, 2008 7:36 pm
by Chalks
I've been googling all over the place, and I'm sure there is an _easy_ answer to this, but I just can't find it. I want to get the data from ONE element on a remote site, and insert it into my own div. I have this:

Code: Select all

   jQuery.ajax({
      url: baseUrl,
      processData: true,  //also tried with false, made no difference that I could see
      dataType: "html",
      success: function(elemented){
        document.getElementById('stuff').innerHTML = jQuery("div.stuffIWant", elemented);  //doesn't work, this is where I need help
      },
      error: function() {
        alert("fail");
      },
    });

Re: Use jquery get specific element from remote page

Posted: Thu Aug 28, 2008 12:09 pm
by kaszu
Inside 'success' function insert this:

Code: Select all

   elemented = jQuery(elemented);
    var css_selector = 'div.stuffIWant';
    var html_content = elemented.find(css_selector).html();
    jQuery('#stuff').html(html_content);