0

I'm trying to display JSON data using jQuery from a Codeigniter controller. I've already created a JSON URL (http://www.tgttest.jeffreyteruel.com/location/locales), and also have the same data on my WAMP server. What I'm having problems is getting the data to display. It works if I take the same JSON data and place it on a .json file, but I'm looking to get it from a Controller/MySql database.

My code is below:

 $.getJSON('http://www.tgttest.jeffreyteruel.com/location/locales', function(data) {
    var output="<ul>";
    for (var i in data.locales) {
        output+="<li>" + data.locales[i].location_id + " " + data.locales[i].location_title  + "</li>";
    }

    output+="</ul>";
    document.getElementById("placeholder").innerHTML=output;
});

It's been a while since I've dealt with AJAX so my skills are rusty. Any help to get the data from the URL is greatly appreciated.

Jeffrey Teruel
  • 364
  • 2
  • 10
  • 29

1 Answers1

0

You need to use CORS or JSONP. Please, read my answer in a similar post: local AJAX-call to remote site works in Safari but not in other browsers

Community
  • 1
  • 1
Jose Mato
  • 2,709
  • 1
  • 17
  • 18