Skip to content

Instantly share code, notes, and snippets.

@WebRTCGame
Created October 23, 2014 18:17
Show Gist options
  • Save WebRTCGame/c87a05333f51340810bb to your computer and use it in GitHub Desktop.
Save WebRTCGame/c87a05333f51340810bb to your computer and use it in GitHub Desktop.
Use jquery to fetch a section of another page on another domain cross site domain
<div id="queryResultContainer">abc</div>
<script>
var ExternalURL = "www.reptilesmagazine.com/Reptile-Events-Calendar/";
$(document).ready(loadContent);
function loadContent() {
var QueryURL = "http://anyorigin.com/get?url=" + ExternalURL + "&callback=?";
$.getJSON(QueryURL, function (data) {
var element = document.getElementById("queryResultContainer");
var html = $.parseHTML(data.contents);
html = $(html).find('#calendar-listings').html();
element.innerHTML = html;
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment