0

How can I load a page using jQuery, AJAX, and JSON? I've tried something like this, but it is not working.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js">

<div id="wsww">content.<div>
<script type="text/javascript">
$.get('https://www.google.com/')
 .success(function(data) {
     $('#wsww').html(data);
 });
</script>
bcr
  • 1,983
  • 27
  • 30
Jan Leon
  • 176
  • 1
  • 14
  • You can't do that. Its a cross domain access. – Jai May 11 '14 at 05:09
  • so theres now way to display data from a different website, because istead of using an iframe i was thinking on using this – Jan Leon May 11 '14 at 05:10
  • Sure there is a way, just not with clientside ajax that violates the same-origin policy – adeneo May 11 '14 at 05:11
  • im not trying to get the content from is a diff website other than google, whats a good idea to use ? – Jan Leon May 11 '14 at 05:13
  • A serverside language comes to mind ? – adeneo May 11 '14 at 05:15
  • **I wrote an answer for 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)** – jherax Jun 26 '14 at 13:54

2 Answers2

0

You don't need the .success function, instead use a callback function... try this

$.get("<url>", function(data){
  $('#www').html(data);
});
Ballbin
  • 717
  • 6
  • 12
  • **I wrote an answer for 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)** – jherax Jun 26 '14 at 13:55
0

Cross Domain Access

HTML

<div id="Content">

</div>    

Jquery

$.getJSON('http://whateverorigin.org/get?url=' + 
          encodeURIComponent('http://google.com') + '&callback=?',
          function(data){

            $("#Content").html(data.contents);
});

Reference

Whateverorigin.org/

codefreaK
  • 3,584
  • 5
  • 34
  • 65