i have been battling with cross domain referencing for days now , i have implemented some examples targeted at public API's that i came across on stack overflow : Basic example of using .ajax() with JSONP? and try to mix it up to work for me but to no avail , my code works on my local host but not on a remote server and here it is
javascript :
function load_data()
{ var data_output = $('#data_output');
$.getJSON("http://localhost/my_CI_root/index/load_data/News/?callback=?", function(response) {
$.each(response, function(i, item){
var landmark = ' <p class="column-responsive half-bottom">'
+ '<img src="http://www.bytepixels.com.ng/decoy/main/report/'+ item.media +'" alt="img">'
+ '<strong>' + item.subject + '</strong>'
+ '<em>'+ item.message + '</em>'
+ '</p><div class="decoration"></div>';
console.log(response);
data_output.append(landmark);
});
});
}
and my codeigniter function:
function load_data($value)
{
header('Content-type: application/json');
$results = $this->my_model->load_data($value);
echo $_GET['callback'] . '(' . json_encode($results) . ')';
}
like i said it works on localhost , im aware of the cross domain constraint and from what i read , $.getJson() is suppose to solve this issue but when i point my URL to http://www.xxxx.com/index/load_data/News/?callback=? it gives me an error 404 , ive tried enabling query strings on Codeigniter but it didnt help , any help would be aprreciated . thank you