Examples of Jquery $. ajax and $. getJson reading local files

Source: Internet
Author: User

Echarts code:

The code is as follows: Copy code
Require ('echarts/util/mapData/params '). params. continent = {
GetGeoJson: function (callback ){
$. GetJSON ('./scripts/continent_geo.json', callback );
}
}

Figure:

 

 

Specified ed an invalid response. Origin 'null' is therefore not allowed access.

After changing to an absolute path, it is like this:

Cross origin requests are only supported for HTTP

Google:

Chrome does not open http requests to local files based on security considerations, so it is unknown for IE and Firefox support.

There are some solutions on the Internet, but none of them succeeded.

Add startup parameters to chrome:

 

The code is as follows: Copy code
-- Allow-file-access-from-files
Or
-- Disable-web-security

Add the startup parameter method to chrome:

Google Chrome shortcut, right-click Properties and add startup parameters to the target location

C: \ Users \ xxx \ AppData \ Local \ Google \ Chrome \ Application \ chrome.exe -- disable-web-security


None of the above two methods can be used.

The best way is to put the folder on the http server for testing. A better way to contact us.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.