Xhynk
Xhynk

Reputation: 13840

Best way to load external content to site (I own all sites) (no iframes?)

I have an ever growing medley of websites that I own (WordPress for the most part if that helps).

Each one has a VERY simple "name, a graphic, and social media links" page on it at foo.domain.com/partner.

I would like for a.domain.com to be able to load content from 3 other sites into their sidebar with OUT iframes.

Is there a better way to do this? Maybe even with .load()? You can't load external content like that I believe, so I'm not sure the best way to approach this. Iframes aren't really cutting it.

Again, I have rights to ALL of the sites, and I have access to add PHP/Jquery scripts anywhere on them all.

Upvotes: 1

Views: 785

Answers (3)

Ben D
Ben D

Reputation: 14479

Lots of ways to do this:

  1. PHP can file_get_contents() or cURL content from other sites and then work with the content server side (load content before it's sent to the browser)
  2. If you are generating content from databases (as you would be in WP) you can connect directly to the MySQL database of your other sites and work accordingly (make sure that you set up MySQL users that can access from the IPs of your other sites (also a server-side method)
  3. Set up cross-domain permissions for javascript and use ajax to load in content (i.e. Access-Control-Allow-Origin)

Upvotes: 7

napolux
napolux

Reputation: 16074

How about JSONP requests? You can avoid the SOP violation.

Upvotes: 1

Liam Allan
Liam Allan

Reputation: 1115

$("#loaddiv").load("directory/file.php").fadeIn("fast");

Upvotes: -5

Related Questions