The format is in ... Nononono, it's totally correct .
JSON is actually a piece of Javascript that is incorporated into the code; this piece of code represents a data structure (a simple element, an array of elements, an associative table of elements)
In
{"nombre" : "pedro"}
you have an associative array with a single element, with key nombre
and value pedro
.
JS allows you to remove the quotes from the element on the left and still consider it as a label; although not so with the one on the right 1 . So:
{nombre : "pedro"}
It is exactly the same as the previous example.
The problem is that JSON is just the data . What you get from JSON must be assigned to a Javascript variable and then processed with your Javascript. What you are doing is loading an incomplete part of the program into the Javascript interpreter, which very logically complains.
What you have to do is, from the JavaScript code , make an Ajax call to the URL and assign the returned value to a Javascript variable. And from there, to get the data of the structure.
To see the difference, a complete JS statement (which does nothing, only defines the structure) would be:
var misDatos = {
Status: 'Success',
Data:{
'primero': {
phone:'5281128043'
}
}
};
Ajax's grace is that the JS program and the data go separately, so you can reload the data without loading the whole page, get data from other servers, etc. The problem is that the way to obtain them is something more complicated than simply writing the JS code.
Here you have a good example to start (in English sorry, but if you search for "JSON Ajax" you will surely find more). link
1 If you remove the quotes from the element on the right, it interprets it as the name of a variable.