0

I want to include only the google results (Div id="ires") for the given URL part. I encountered for example the "No 'Access-Control-Allow-Origin'"- Problem and I wonder how to solve this.

I started a JSfiddle here with my try: http://jsfiddle.net/23z7w3xp/1/

HTML:

<div id="results">Waiting for results</div>
<input type="button" id="btn" value="Show results">

JS:

$("#btn").click(function () {
    var requesthtml = "https://www.google.de/?gfe_rd=cr&ei=pXVyVKCDJKeK8QfkkoDYCg#q=test";

    $.get( requesthtml, function( data ) {
      var htmlcontent = data;
      $('#results').html(htmlcontent.find('#ires').text());
      alert( "Load was performed." );
    });
});
kentor
  • 16,553
  • 20
  • 86
  • 144
  • It is completely impossible to do that. – SLaks Nov 24 '14 at 00:25
  • It isn't for sure. Maybe only with javascript, but I can use php ofcourse as well – kentor Nov 24 '14 at 00:26
  • 1
    You can't access another domain's content directly via JavaScript unless they specifically allow CORS and/or provide a JSONP endpoint. One way to do it is via a backend "proxy" or something similar. Here is a simple example project where it's done with PHP and jQuery Ajax: https://github.com/vasilionjea/google-analytics-verify Please note that I can't advise you on the legality of it though. – istos Nov 24 '14 at 00:35

0 Answers0