File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 60050
    
  65

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...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Json error
 
Similar Threads
jQuery in Action: Can I use jQuery to go across domains
Form Plugin Form Reference On Success callback
json object send to JSF backing bean to xhtml page
Undefined on jQuery Ajax Request
Ajax JSON looping in jQuery