Reputation: 53
i'm loading a site "B", which is using canvas, into site 'A'. iframe was an easy option and is working great but i want to do it using jQuery. I tried using ".load" and "$.ajax" the site "B" is giving error javascript is disabled on your browser...below is the code...
if i directly load that site into another window it works well..I do not want to use iframe .. i need to load it in some div
using .load...
$("#dataLoader").load('http://www.xyz.com');
and using ajax...
$.ajax({
url: "http://www.xyz.com",
cache: false
}).done(function( html ) {
console.log(html)
$("#dataLoader").append(html);
});
Upvotes: 0
Views: 2715
Reputation: 11381
This cannot be done without an iFrame. iFrames are specifically built to load pages. ajax
cannot be used for content-injection from cross domains. There are many alternatives/fixes to rectify this :
url
attribute of the iframe to the target page and be done with it. src
attribute within the HTML itself. No jQuery would be needed then.jsop
if cors
is supported by the server on which xyz.com
is hosted on.ajax
and jquery for this, use this extra mod to the ajax
library : http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/ajax
to get that out. Please look at these links for more clarity on this :
Upvotes: 1
Reputation: 1098
Just change the src
attribute of the iframe. Something like
$("#frame").attr("src", url);
Upvotes: 0