[jQuery] problems with each() and JSON
Hi Folks,
i have a big roblem with a little getJSON request. At first..this is my code:
=== HTML ===
<button>dicken ajax-request ausführen!</button>
<ul id="myList">
</ul>
</body>
=== JavaScript ==
$(function(){
$("button").click(function(){
$.getJSON("myJson.js", myCallback);
function myCallback (jsonObject){
$(jsonObject.aString).each(function(){
$("#myList").append("<li>" + this + "</li>");
});
}
});
});
=== The JSON document ===
{
"anInt": 5555,
"aFloat": 55.055,
"aString": "testing",
"aBoolean": true,
"anArray": [
1,
"2",
3.34,
"dog"
],
"anObject": {
"prop1": "a value",
"prop2": "another value",
"prop3": -9999
},
"aNull": null
}
you can also see this online at <a href="http://pattentrick.de/my_jquery_json/index.html">http://pattentrick.de/my_jquery_json/index.html</a>
So here is finally my problem. I can just get numbers or bools of this JSON document. When i am trying to get a string e.g. nothing happens. No fanncy things, and no errors in my firebug console. I think its a problem with the each() function. I tried everything i could imagine till now. But nothing seems to work. Is there somone in this mailinglist who could help me...please?
Kind Regards,
The Pattentrick