How do I convert this ajax response to a jquery object


I'm trying to get the contents of a page and manipulate it just as I would with any jquery object but I'm unable to do so. I've tried using parseHTML and simply throwing it into the jquery function like so $($.trim(res)).jqueryMethod(); in both cases, I get an array of jquery objects which do not run any jquery methods whatsoever. They're all dormant.

The current code is as follows

$.get('').done(function(page) {

How do I go about getting a jquery object from which I can find() for instance? Thanks.


That should actually work out of the box... especially since you already confirmed that jQuery correctly recognises the response as HTML. Note however that the page you're fetching is an AngularJS app, so a lot of content will be missing in the initial markup.


Hello @m3g4p0p. Long time no see. The response from that page can be seen at Can you get the element '.nivoo-slider-holder a'? Many thanks.


Well there is no .nivoo-slider-holder element -- you can just do a plain text search for that class name on the response data. If you try to .find() say .header_menu_item you'll get a match though, so it definitively works.


My guess is that access to that URL is restricted due to the cross origin domain policy. Simply put you can't access any pages of a website which are not part of the same domain as your website in client-side JavaScript. Check the network activity in the browser using debug tools available on most browsers like Chrome. You can view the outbound traffic and see the request/response to verify.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.