After performing XMLHttpRequest how can I parse responseText with jquery? I tried
var parsed = $.parseHTML(data);
but the result is DOM array and I can not select anything by
$(parsed).find('#myIDobject')
or so.
After performing XMLHttpRequest how can I parse responseText with jquery? I tried
var parsed = $.parseHTML(data);
but the result is DOM array and I can not select anything by
$(parsed).find('#myIDobject')
or so.
And if not a collection of DOM elements, then what did you expect?
If the element you're trying to "find" is at root level, you'll need to use filter:
var parsed = $.parseHTML(data);
var element = $(parsed).filter('#myIDobject');
and to avoid the issue completely, you can do:
var parsed = $.parseHTML(data);
parsed = $('<div />').append(parsed);
parsed.find('#anything');