Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Parse JSON URL

Tags:

json

jquery

I am trying to get the JSON data from a URL that outputs the following JSON data:

[
 {
    "belief_desc":"Jesus Died For Your Sins",
    "0":"Jesus Died For Your Sins"
 },
 {
    "belief_desc":"People Are Sinful",
    "0":"People Are Sinful"
 },
 {
    "belief_desc":"God Loves You",
    "0":"God Loves You"
 },
 {
    "belief_desc":"We Must Receive Christ",
    "0":"We Must Receive Christ"
 }
]

(Note: it is only formatted in this question for easier reading.)

Now I am trying to parse through it using this simple jQuery script:

<script>
    var url = "http://mySite.com/data.json";
    $.getJSON(url, function(data){
        alert(data);
        });
</script>

I am getting no data from the URL as the alert will not show. Any ideas on why this is not working?

like image 855
Mike Richards Avatar asked Oct 05 '22 03:10

Mike Richards


1 Answers

Cross domain you can't do simple JSON.

Basic how-to for cross domain jsonp

Read up on cross domain requests.

like image 78
Leeish Avatar answered Oct 13 '22 11:10

Leeish