aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Json error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Json error" Watch "Json error" New topic
Author

Json error

tural ferhadov
Greenhorn

Joined: Oct 20, 2012
Posts: 7
I have trouble with appending json elements to div...
my json is : {"childNodes":[{"categoryId":904,"categoryName":"wee"}]}
I want to append all names to div with each...

success: function(data) {

$.each(data.childNodes,function(i,c){
$("#childNodesDiv").html(c.categoryName);

});
}

But I get an errror stating that cannot read length property of undefined ..





Someone, please help me
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

Use the built-in JavaScript debugger to set breakpoints and see what value is undefined. Once we know that, we can find out why it is undefined.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
childNodes has meaning in JavaScript, that is not the best name to use.
tural ferhadov
Greenhorn

Joined: Oct 20, 2012
Posts: 7
I changed the name of variable , but again same mistake... "data.cNodesList undefined "
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Are you sure that data is a JSON object? DId you debug it?

tural ferhadov
Greenhorn

Joined: Oct 20, 2012
Posts: 7
It was not Json object, I didnot noticed that datatype was just an object, not json object. Already figured out. It was a silly mistake. I just did not write dataType:json . Thank you very much...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Json error