Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Unable to resolve XML http request

Posted on 2016-09-28
4
Medium Priority
?
130 Views
Last Modified: 2016-10-12
This is the error

perjs.html:1 XMLHttpRequest cannot load https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8….1957362&radius=10000&type=gym&key=AIzaSyCaFrzxzjNiBSWLaZ3_cm753jV5OQbFiDM. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.




This is the code...

<html>
  <head>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
  <script>
  $(document).ready(function(){
    $.getJSON('https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=10000&type=gym&key=AIzaSyCaFrzxzjNiBSWLaZ3_cm753jV5OQbFiDM', function(myJSONResult){
      var myAddress = [];
      for (i = 0; i < myJSONResult.results.length; i++) {
        myAddress[i] = myJSONResult.results[i].formatted_address;
        alert(myAddress[i]);
      }
      
    });
  });

  </script>

  </head>
  <body>
  
  </body>
  </html>

Open in new window

0
Comment
Question by:yogesh byahatti
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 19

Expert Comment

by:Albert Van Halen
ID: 41821381
Why don't you make use of the places service?
To bad the places service need an instance of a map, but you don't have to use the map.
Have a look at this fiddle : https://jsfiddle.net/avanhalen/n5s4r3re/

I also updated the fiddle to show the markers on the map : https://jsfiddle.net/avanhalen/n5s4r3re/1/
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 1000 total points
ID: 41822030
you should do the request usin a server with PHP.
check this post for example :
https://www.experts-exchange.com/questions/28545160/PHP-variable-question.html
0
 

Author Comment

by:yogesh byahatti
ID: 41830477
Albert Van Halen

Thank you for the help. :)

But I am looking to parse the json data from the Google places api.
Please look at this

URL:https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=10000&type=gym&key=AIzaSyCaFrzxzjNiBSWLaZ3_cm753jV5OQbFiDM


From this URL I want to retrieve Json data
0
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 1000 total points
ID: 41830618
Well, you can.
In the example page I gave you I did it by showing markers on the map.
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question