JQuery $ .each only returns first JSON element




I have a JSON object like:



```
{
    "mesta": [
        {
            "latlng": [49.094046,15.893415],
            "nazev": "Město Jaroměřice nad Rokytnou"
        },
        {
            "latlng": [49.44119,18.09461],
            "nazev": "Obec Vidče"
        },
        {
            "latlng": [49.5047,17.10139],
            "nazev": "Obec Smržice"
        }
    ],
    "orp": [
        {
            "latlng": [49.2156,15.87819],
            "nazev": "Město Třebíč (ORP)"
        },
        {
            "latlng": [49.457623,18.142622],
            "nazev": "Město Rožnov pod Radhoštěm (ORP)"
        }
    ]
}

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
```

When I try to iterate over the object, I only get the first item (mesta) in alert mode. According to jsonlint, the syntax is correct. Did I miss something?



```
function loadMarkers() {
    $.getJSON('data.json', function(data) {

        $.each(data,function(index,obj) {
                alert(index);
        });
    });
}

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
```
The problem is the response from the server, not your JavaScript. I ran the following code in the console on your page:



```
$.getJSON('data.json', function(data) { 
    console.log(data); 
});

        

        
        
        
 (adsbygoogle = window.adsbygoogle || []).push({});
 
        

    
```

The result looks like this:



  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

 ![enter image description here](https://fooobar.com//img/b0b4666ec951695a00da8c82eb85e737.jpg)


As you can see, there is only one property in the returned object ( `mesta`
  




 (adsbygoogle = window.adsbygoogle || []).push({});
 
  

, an array with three elements).


You can confirm this by [visiting the file directly`data.json`
  




 (adsbygoogle = window.adsbygoogle || []).push({});](https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=) .
Your function works, but both the IF and the ELSE return an alert message that says its invalid.  

The first part - the IF - should return in the alert box "Valid SSN"  

I am assuming your input should be like this 123-45-1234


but do you need to tell the user the input is valid? Surely the alert should only be displayed if the input is invalid? So the if should return nothing. imho the json fragment you have there is a json list, not a json map (notice the outermost square brackets). use apoc.convert.fromjsonlist() you should extract from the reply json object the “url”, and send a post with “{}” payload to trigger the identifier challenge verification. check rfc8555. JavaScript *itself* has nothing built in for handling query string parameters. 


Code running in a (modern) browser you can use the [`URL` object](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) (which is part of the APIs provided by browsers to JS):





```
var url_string = "http://www.example.com/t.html?a=1&b=3&c=m2-m3-m4-m5"; //window.location.href
var url = new URL(url_string);
var c = url.searchParams.get("c");
console.log(c);
```









For older browsers (including Internet Explorer), you can use [this polyfill](https://github.com/ungap/url-search-params) or the code from the original version of this answer that predates `URL`:


You could access `location.search`, which would give you from the `?` character on to the end of the URL or the start of the fragment identifier (#foo), whichever comes first.


Then you can parse it with this:





```
function parse_query_string(query) {
  var vars = query.split("&");
  var query_string = {};
  for (var i = 0; i < vars.length; i++) {
    var pair = vars[i].split("=");
    var key = decodeURIComponent(pair[0]);
    var value = decodeURIComponent(pair[1]);
    // If first entry with this name
    if (typeof query_string[key]  "undefined") {
      query_string[key] = decodeURIComponent(value);
      // If second entry with this name
    } else if (typeof query_string[key]  "string") {
      var arr = [query_string[key], decodeURIComponent(value)];
      query_string[key] = arr;
      // If third or later entry with this name
    } else {
      query_string[key].push(decodeURIComponent(value));
    }
  }
  return query_string;
}

var query_string = "a=1&b=3&c=m2-m3-m4-m5";
var parsed_qs = parse_query_string(query_string);
console.log(parsed_qs.c);
```




You can get the query string from the URL of the current page with:



```
var query = window.location.search.substring(1);
var qs = parse_query_string(query);

``` You need to iterate over the resource...

 
```
while ($row = mysql_fetch_object($tariff_query)) {
    echo $row->somefield;
    echo $row->someotherfield;
}

```
 So you now get all the records not just the first one.

 BTW, if you want to use an object, why not use PDO or mysqli? mysql is dead - or as good as. In order to correctly map you need to use the multi-map functionality.



```
 var points = this._db.Query<Point, Address, Point>("select p.Id, 'x' [Id], p.Address_City [City], p.Address_State [State] from Points p", (p, a) =>
            {
                p.Address = a;
                return p;
            }).ToList();

``` hi [@jason.danforth](/u/jason.danforth),

all objects in the document are stored in the objecttable (rhino.docobjects.tables.objecttable). if you just want to select them, you can loop through them and use objecttable.select() method

import rhino

for robj in rhino.rhinodoc.activedoc.objects:

if robj.isnormal:

… Reason: `s` starts at 1 and is incremented on first call, but is never reset. On seconds and subsequent calls `s` no longer starts at 1. `s` is actually unnecessary as you can use the loop counter `i` instead.



A more conventional way to do this sort of thing would be with a single function, not embedded in an object, and to control the detailed behaviour by passing parameter(s).



```
function loadGame(level){
	var values;
	switch(level){
		case 'hard':
			values: [7,8,9],
		break;
		case 'normal':
			values: [4,5,6],
		break;
		default://easy
			values: [1,2,3],
	}
	for(i=0;i<=this.values.length;i++){
		document.getElementById('n'+i).innerHTML=this.values[i];
	}
}
```


```
<div id="n0"></div>
	<div id="n1"></div>
	<div id="n2"></div>
	<input type="button" value="easy" onClick="loadGame('easy')"/>
	<input type="button" value="normal" onClick="loadGame('normal')"/>
	<input type="button" value="hard" onClick="loadGame('hard')"/>
```

**Airshow** i do not write go, but it seems like your

func(w http.responsewriter

should be similar to

responsewriter.header().set("content-type", "application/json")

responsewriter.writeheader(http.statusok)

jsondata := []byte(`{}`)

responsewriter.write(jsondata) hi thomas luck, - - the example i've sent you is not initializing the value from the web service result. you should do this by code like this: - - for (var i = 0; i - { -        var item = new telerik.web.ui.radmenuitem(); -        item.set\_text(result[i].text); -        item.set\_value(result[i].value); -        item.set\_expandmode(result[i].expandmode); -        menu.get\_items().add(item); - } - - regards, - albert - the telerik team - - - check out - telerik trainer - , the state of the art learning tool for telerik products. - -