0

I'm trying to extract an element's children from an AJAX call, but am having difficulty isolating it. My code is as follows:

function AJAXcomplete(data){
    var result = $(data).find('#productDetails > *');
    jQ('#productDetails').append(result);
};

function getDetails(e){
    e.preventDefault();
    var addy = jQ(this).attr("href");
    jQ('body').append('<div id="productDetails"></div>');
    jQ('#productDetails').show();
    $.get(addy, AJAXcomplete);
};

jQ('#slides').on('click', '.slideLink', getDetails);

The above should append the children of #productDetails from the AJAX call, and append them to a newly created div of the same id.

I can successfully retrieve the entire AJAX data and append that (tested) but I can't get the element I want. Am I doing something obviously wrong?

1
Contributor
1
Reply
6
Views
4 Years
Discussion Span
Last Post by chr.s
0

Changing

var result = $(data).find('#productDetails > *');

to

var result = $(data).filter('#productDetails').children();

solved the issue.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.