简体   繁体   中英

JSON_2_Region.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

I am developing the mobile application using ADT there and I am facing error

"No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access."

while my code reads from the path testapp/assets/www/Pages/JSON_2_Region.json

Here is my code:

  $.getJSON('JSON_2_Region.json', function (data) {
                $('#List_Region_Details').empty();
                $('#JSON_2_Region li').remove();
                region_list = data.JSON_MAS_Data_Region;                                                            

                $.each(region_list, function (index, JSON_MAS_Data_Region) {
                    $('#List_Region_Details').append('<li><a href="" data-id="' + JSON_MAS_Data_Region.Region_ID + '">' + JSON_MAS_Data_Region.Region_Name + '</a></li>');
                });

                $('#List_Region_Details').listview('refresh');
            });

The error happens only in the Chrome browser when I copy/paste the url seperately but works fine in my ADT default browser and emulator.

If you want to testing using your browser, you need to use ripple chrome extension to run in mobile environment. You will got this error message if you not run the app in mobile environment.

Uncaught ReferenceError: cordova is not defined

https://chrome.google.com/webstore/detail/ripple-emulator-beta/geelfhphabnejjhdalkjhgipohgpdnoc?hl=en

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM