0

I'm using this plugin: https://github.com/padolsey/jquery.fn/tree/master/cross-domain-ajax/

And this is my code:

   $.ajax({
      dataType: 'html',
      type: 'GET',
      url: 'http://www.google.com',
      crossDomain: true
  }).done(function(data) { 
       $("#box").html('').append(data);
  });

From my understanding, even though I have dataType: 'html' I'm fairly sure this is still getting me a response in JSONP.

I want to be able to grab the entire html of the page, everything I need to display the page in full. Comparable to an iframe. The reason I need to do this through ajax is because eventually I am going to need to pass parameters to the URL I am using. What is the best way to return a page's content in full HTML, so that I may display the page? Do I need to do anything to return the pages scripts/stylesheets as well?

Basically, the URL that I am calling needs to be returned so that I can append the return to a div id, and that div id should then look exactly like the page I was calling, as if I were to load that page independently in a browser window.

Thanks!

Seth McClaine
  • 9,142
  • 6
  • 38
  • 64
jamesdlivesinatree
  • 1,016
  • 3
  • 11
  • 36
  • **I wrote an answer related to this question here: [Loading cross domain html page with jQuery AJAX](http://stackoverflow.com/questions/15005500/loading-cross-domain-html-page-with-jquery-ajax/17299796#17299796)** – _the last one, supports https_ – jherax Jun 26 '14 at 17:11

2 Answers2

0

Plugin referenced uses Yahoo YQL service as a proxy to get remote page. YQL will return json and you should be able to access your data in data.responseText. This is per limted docs for plugin

To be sure you can log the data to console and see it's structure.

Could do same thing without plugin by using YQL console to create URL needed to meet your scraping needs using their XPATH syntax

charlietfl
  • 170,828
  • 13
  • 121
  • 150
0

You can try Ajax-cross-origin a jQuery plugin.

http://www.ajax-cross-origin.com/

    $.ajax({
        crossOrigin: true,
        url: url,
        success: function(data) {
            console.log(data);
        }
    });
Ninioe
  • 520
  • 1
  • 6
  • 6