I am requesting a website with JQuery’s ajax function. I am a little bit unclear about the responseType of the XHR request. So far I am using the “dataType: “html”” attribute but I am not happy with it.
I’d rather have a complete HTMLDocument returned which would allow me traverse its DOM tree and scrape information as needed. I believe the “document” responseType is supported by XHR2 requests.
How can this be done with JQuery? Is there a way that it will return a DOMtree that I can navigate through?
Simply add the following to your
$.ajax()call:To retrieve the document object, your
successcall should look like this: