When reading data from your server, you cannot obtain the data from the following external sources, and add the header (& #039; content-type: application: json; charsetutf8 & #039;); header (& #039; access-Control-Allow-Origin: * & #039;); header (& #039; Access-Control-Allow-Methods: POST & #039 ;); header (...
When reading data from your own server
Data cannot be obtained externally.
Header ('content-type: application: json; charset = utf8 ');
Header ('access-Control-Allow-Origin :*');
Header ('access-Control-Allow-Methods: Post ');
Header ('access-Control-Allow-Headers: x-requested-with, content-type ');
After
Why are the following results in json format different from those received?
Reply content:
When reading data from your own server
Data cannot be obtained externally.
Header ('content-type: application: json; charset = utf8 ');
Header ('access-Control-Allow-Origin :*');
Header ('access-Control-Allow-Methods: Post ');
Header ('access-Control-Allow-Headers: x-requested-with, content-type ');
After
Why are the following results in json format different from those received?
Jsonp for cross-origin Data Retrieval
It is clearly written that an array containing two elements and the data passed throughJSON.strigify()
AndJSON.parse()
Can be converted to each other.
... Special interfaces are required for cross-origin, not any interface for returning data.
Jsonp, script, and other labels are required. The returned result is a function with parameters instead of simple data...
Between...
Of course, the json format can be an array, a string, or an object.
JSON.parse('true');JSON.parse('false');JSON.parse('1');JSON.parse('0');JSON.parse('"hello"');JSON.parse('""');JSON.parse('[]');JSON.parse('{}');
Theoretically, JSON objects can be correctly converted by json. parse. At the same time, we also need to distinguish what is a json string and what is a json object.
header('content-type:application:json;charset=utf8');
The browser directly parses the result as json.
One is a string and the other is json, so there is no difference... just convert it.