0

Currently using Agile Carousel in order to have some images carousel through, however trying to use this as a banner ad served through DART.

Issue being with the PHP file being served on a different server, i know that JSONP is the answer but not sure how to adapt my code and PHP file to represent this, any help would be great.

$.getJSON("[PHP FILE SERVED ELSEWHERE]", function (data) {
$(document).ready(function () {
$("#basic_slideshow").agile_carousel ({
carousel_data: data,
carousel_outer_height: 70,
carousel_height: 70,
slide_height: 70,
carousel_outer_width: 422,
slide_width: 422,
transition_type: "slide",
timer: 4000

The PHP file being called by the getJSON looks like:

[{
"content": "<div class='slide_inner'><a class='photo_link' href='[URL1]'
target='_blank'><img class='photo' src='[IMAGE1]' alt=''></a><a class='caption'
ref='#'></a></div>"
}, {
"content": "<div class='slide_inner'><a class='photo_link' href='[URL2]'
target='_blank'>
img class='photo' src='[IMAGE2]' alt=''></a><a class='caption' href='#'></a></div>"
}, {
"content": "<div class='slide_inner'><a class='photo_link' href='[URL3]'
target='_blank'><img class='photo' src='[IMAGE3]' alt=''></a><a class='caption'
href='#'></a></div>"
}
]

I'm sure there are similar questions out there but I just couldnt figure out the best way to adapt both the javascript and the PHP file to cater for the JSONP request.

Thanks in advance!

Daffy Kyle
  • 13
  • 3
  • 1
    You probably miss callback, here is similar topic that might help you http://stackoverflow.com/questions/6809053/simple-jquery-php-and-jsonp-example – Ivan Lazarevic May 29 '12 at 10:57

1 Answers1

0

Rather than editing the JSON I actually found that due to the permissions issues with cross-server domain linking (basically sourcing the PHP file from a domain not contained on the actual server) there was a permissions change you can put in the header of the PHP file.

I'm sure there are the obvious benefits to using JSONP and security is probably more secure, but for somebody with extremely basic coding skills this solution worked and was easy!

I added this to the PHP file to allow cross-domain permissions:

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

The allow origin can also be restricted to a domain, the * obviously allows all.

Daffy Kyle
  • 13
  • 3