JS / JQuery character problem

Posted by Jimmy Farax on Stack Overflow See other posts from Stack Overflow or by Jimmy Farax
Published on 2010-05-31T21:53:18Z Indexed on 2010/05/31 22:03 UTC
Read the original article Hit count: 230

Filed under:
|
|

I have a code which has a character that JS is not handling properly.

$(document).ready(function(){


    $.getJSON("http://sjama.tumblr.com/api/read/json?callback=?",
        function (data){
            for (var i=0; i<data.posts.length; i++){

                    var blog = data.posts[i];

                    var id = blog.id;
                    var type = blog.type;

                    var photo = blog.photo-url-250;

                    if (type == "photo"){

                        $("#blog_holder").append('<div class="blog_item_holder"><div class="blog_item_top"><img src='+photo+'/></div><div class="blog_item_bottom">caption will go here</div></div>');
                    }

            }

        }); <!-- end $.getJSON

});

The problem is with this line:

   var photo = blog.photo-url-250;

after "blog." it reads the "url" part weirdly because of the dash (-) in between.

What can I do to sort this problem out?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about character