Note that there are some explanatory texts on larger screens.

plurals
  1. POjson parse with jQuery loop
    primarykey
    data
    text
    <p>hi my code is attached below, though its a part of bigger code</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; #results{margin-top:100px; width:600px; border:1px solid #000000; background-color:#CCCCCC; min-height:200px;} &lt;/style&gt; &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"&gt;&lt;/script&gt; &lt;script src="https://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="results"&gt;&lt;/div&gt; &lt;script&gt; var input="Taj Mahal India"; var url = "http://maps.googleapis.com/maps/api/geocode/json?address=" + input + "&amp;sensor=false"; var check = $.getJSON(url, function (data) { console.log("inside getjson"); console.log(data); $.each(data.results.address_components, function(i,inside){ if(inside.types[0]=="route"){ $("#results").append('&lt;p&gt; route : '+this.long_name +'&lt;/p&gt;'); } if(inside.types[0]=="locality"){ $("#results").append('&lt;p&gt; locality : '+this.long_name +'&lt;/p&gt;'); } if(inside.types[0]=="administrative_area_level_2"){ $("#results").append('&lt;p&gt; administrative area 2 : '+this.long_name +'&lt;/p&gt;'); } if(inside.types[0]=="administrative_area_level_1"){ $("#results").append('&lt;p&gt; administrative area 1 : '+this.long_name +'&lt;/p&gt;'); } if(inside.types[0]=="country"){ $("#results").append('&lt;p&gt; country : '+this.long_name +'&lt;/p&gt;'); } }); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The problem is that it doesn't work. I have a strong doubt that i have done something wrong in <code>$.each(data.results.address_components, function(i,inside)</code> line.</p> <p>JSON for Taj Mahal India is here <a href="http://maps.googleapis.com/maps/api/geocode/json?address=Taj%20Mahal%20India&amp;sensor=false" rel="nofollow">http://maps.googleapis.com/maps/api/geocode/json?address=Taj%20Mahal%20India&amp;sensor=false</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload