Jump to content

JSON help


dennismonsewicz

Recommended Posts

I have the following JSON:

 

([
{"name":"question me?", "answers":["Hello", "Testing"]}
])

 

and the following jQuery:

 

<script type="text/javascript">
	 $(function() {
		 //retrieve comments to display on page  
		 $.getJSON("javascripts/newdisp.js", function(data) {  

		 //create a container for each comment  
		 var div = $("<div>").appendTo("#jsonHere");

		  for (var x = 0; x < data.length; x++) {                 
			 $("<label>").text(data[x].name).appendTo(div);		 
		   }
		   
		   for (var z = 0; z < data.length; z++) {
			$("<div>").text(data[z].answers).appendTo(div);
		   }
		   
		 });           
	   });         
</script>

 

I am trying to get the individual answers to show up... and its not working lol... any help?

Link to comment
https://forums.phpfreaks.com/topic/153959-json-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.