Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load a PHP page's div on another page on other domain

Goodmorning, I've this situation:

I'm working with Wordpress and I'm trying to create an affiliate box for our affiliates. I've created it dynamically and you can see one example here

Values for the creation of the box are passed with $_GET and the box is created by a php function called before the_content() on the template page.

The box, if you load the page directly, works fine.

But I'm trying to load that specific div into another page and for test I'm trying to load it into a page of my same domain.

The page for the test is here

I'm using jQuery load() function for the loading, like this:

jQuery(document).ready(function(){
   var valore = jQuery('#cm_aff_box_container').text();
   jQuery('#cm_aff_box_container').empty().load('http://www.clubmagellano.it/affiliate-box/?value='+valore+' #cm_affiliate_box', function(){/*Other stuff here*/});
    });     
});

Unfortunately it won't load anything in the div. I've tried to load the page directly and it loads correctly despite the fact that also in this case my affiliate box is not loaded.

I've also read that the load() function won't work for other domains and I need that portability. How can I solve this problem?

==========UPDATE===========

I've resolved, and the box is loaded within my domain. The problem is, how can I load it on another domain?

==========UPDATE 2.0 ===========

Guys I've resolved putting this:

<?php header("Access-Control-Allow-Origin: *"); ?>

To the header.php file of the domain which create the box. It works perfectly!

like image 420
Dman88 Avatar asked Dec 19 '12 15:12

Dman88


1 Answers

Why not use an iframe? It's typically used to display ads in a page.

<iframe id="cm_affiliate_box"></iframe>

.
.
.

jQuery(document).ready(function(){
   jQuery('#cm_affiliate_box').attr('src', 'http://www.clubmagellano.it/affiliate-box/?value='+valore+' #cm_affiliate_box');     
});
like image 140
Samuel Avatar answered Nov 03 '22 19:11

Samuel