I am calling a jquery function from .aspx page as follows

```
 <body onload="JavaScript:createPanels('[{a,b,c,d,e}]')">

```

in my jquery I have function defined as 

```
function createPanels(requiredButtons) {
    var abc = JSON.stringify(requiredButtons)
    abc.each(function (key, value) {
        alert(value);
    });

}

```

Now the issue is that I am not getting any alert.

Can any one point me where am I going wrong?
['https://Stackoverflow.com/questions/17804096', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1243271/']
Several issues there.

a. This is not JSON `[{a,b,c,d,e}]`

If you really want to do it on the body element then this is how to do it:

```
<body onload="JavaScript:createPanels('{&#34;posts&#34;: [{&#34;key&#34;:&#34;value&#34;}, {&#34;key&#34;:&#34;value&#34;}]}')">

```

This is not a really good idea, so you call it in a jquery page load handler:

```
$(document).ready(function(){
  //create the JSON object here
  //call the function here
}); 

```

b. Change your script too:

```
function createPanels(requiredButtons){
    var abc = JSON.parse(requiredButtons);
    $(abc).each(function (key, value) {
         alert(value);
    });
}

```
"{a,b,c,d}" is not a object that's why your code is not working.

Second point is : **Use jQuery.each() for iterating a collection.**

Try to put it in this form :

```
var x= ['a','b','c','d','e'];
jQuery.each(x,function (key, value) {
        console.log(value);
});

```

It will return **a,b,c,d,e** as you want.

Here is the working [demo](http://jsfiddle.net/MzxPk/)