Good evening. I have JSON

[ { "icon": "images/status/icon01.jpg", "ticket": "001", "title": "ВывСсти счСтчик ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΉ ΠΈ Π΄ΠΎΠ³ΠΎΠ²ΠΎΡ€ΠΎΠ².", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "23.12.15", "update": "27.12.15", "deadline": "31.12.15" }, { "icon": "images/status/icon02.jpg", "ticket": "002", "title": "ΠžΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Kaod getProducts.", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "17.12.15", "update": "22.12.15", "deadline": "7.01.16" }, { "icon": "images/status/icon03.jpg", "ticket": "002", "title": "ВывСсти счСтчик ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΉ ΠΈ Π΄ΠΎΠ³ΠΎΠ²ΠΎΡ€ΠΎΠ².", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "04.12.15", "update": "---", "deadline": "15.02.16" }, { "icon": "images/status/icon04.jpg", "ticket": "002", "title": "ΠžΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Kaod getProducts.", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "29.11.15", "update": "15.12.15", "deadline": "25.12.15" }, { "icon": "images/status/icon01.jpg", "ticket": "001", "title": "ВывСсти счСтчик ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΉ ΠΈ Π΄ΠΎΠ³ΠΎΠ²ΠΎΡ€ΠΎΠ².", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "23.12.15", "update": "27.12.15", "deadline": "31.12.15" }, { "icon": "images/status/icon02.jpg", "ticket": "002", "title": "ΠžΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Kaod getProducts.", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "17.12.15", "update": "22.12.15", "deadline": "7.01.16" }, { "icon": "images/status/icon03.jpg", "ticket": "002", "title": "ВывСсти счСтчик ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΉ ΠΈ Π΄ΠΎΠ³ΠΎΠ²ΠΎΡ€ΠΎΠ².", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "04.12.15", "update": "---", "deadline": "15.02.16" }, { "icon": "images/status/icon04.jpg", "ticket": "002", "title": "ΠžΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Kaod getProducts.", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "29.11.15", "update": "15.12.15", "deadline": "25.12.15" }, { "icon": "images/status/icon01.jpg", "ticket": "001", "title": "ВывСсти счСтчик ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΉ ΠΈ Π΄ΠΎΠ³ΠΎΠ²ΠΎΡ€ΠΎΠ².", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "23.12.15", "update": "27.12.15", "deadline": "31.12.15" }, { "icon": "images/status/icon02.jpg", "ticket": "002", "title": "ΠžΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Kaod getProducts.", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "17.12.15", "update": "22.12.15", "deadline": "7.01.16" }, { "icon": "images/status/icon03.jpg", "ticket": "002", "title": "ВывСсти счСтчик ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΉ ΠΈ Π΄ΠΎΠ³ΠΎΠ²ΠΎΡ€ΠΎΠ².", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "04.12.15", "update": "---", "deadline": "15.02.16" }, { "icon": "images/status/icon04.jpg", "ticket": "002", "title": "ΠžΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Kaod getProducts.", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "29.11.15", "update": "15.12.15", "deadline": "25.12.15" }, { "icon": "images/status/icon01.jpg", "ticket": "001", "title": "ВывСсти счСтчик ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΉ ΠΈ Π΄ΠΎΠ³ΠΎΠ²ΠΎΡ€ΠΎΠ².", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "23.12.15", "update": "27.12.15", "deadline": "31.12.15" }, { "icon": "images/status/icon02.jpg", "ticket": "002", "title": "ΠžΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Kaod getProducts.", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "17.12.15", "update": "22.12.15", "deadline": "7.01.16" }, { "icon": "images/status/icon03.jpg", "ticket": "002", "title": "ВывСсти счСтчик ΠΊΠΎΠΌΠΏΠ°Π½ΠΈΠΉ ΠΈ Π΄ΠΎΠ³ΠΎΠ²ΠΎΡ€ΠΎΠ².", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "04.12.15", "update": "---", "deadline": "15.02.16" }, { "icon": "images/status/icon04.jpg", "ticket": "002", "title": "ΠžΠΏΡ‚ΠΈΠΌΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ Kaod getProducts.", "p": "__", "status": "ΠžΡ‚ΠΊΡ€Ρ‹Ρ‚ΠΎ", "solution": "РСшСниС", "create": "29.11.15", "update": "15.12.15", "deadline": "25.12.15" } ] 

does not display data in chromium, although it fires on firefox, but it swears.

  • This is a chromium jquery.min.js error: 4 XMLHttpRequest cannot load load: ///home/user/Documents/jquery_test/test_1.json. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

-This is a firefox XML error. Parsing Error: syntax error Location: file: ///home/user/Documents/jquery_test/data.json Line Number 1, Column 1:

I'm doing on jQuery

code next

  var getTasksList = function (url, showTasks) { jQuery.ajax({ url: url, dataType: 'json', method: 'GET', success: function (data) { showTasks(data); }, error: function (jqXHR, textStatus) { console.log('error'); } }); }; 
  • one
    You make a request to local files - this is not safe, firefox permits this "out of the box", in chrome, you need to disable web security in the settings - MedvedevDev

1 answer 1

Cross origin requests are only supported for protocol ... https://stackoverflow.com/questions/10752055/cross-origin-requests-are-only-supported-for-http-error-when-loading-a-local

This error means that the browser blocks cross-domain requests. Cross-domain requests are requests that have different domains, i.e. in your case:
Your domain, for example - localhost /

The request goes from the domain "localhost /" to "file: ///home/user/Documents/jquery_test/data_1.json"

The browser sees that the request went to the wrong domain (i.e., not to the address localhost /.../data_1.json, but to the address file: ///home/.../data_1.json) and interprets this as cross-domain query.

In general, requests should go to the address "localhost / jquery_test / data_1.json" in this case (well, or any other way, but this path should contain your domain, from which the request leaves, that is, if simpler, put json- file in the folder with your script and refer to the path of the file)

Here you can also read about cross-domain queries https://learn.javascript.ru/xhr-crossdomain

  • Thank you for the detailed answer, and the article provided! - Ilya Rogatkin