samedi 14 février 2015

Dynamic html elements show only when going through debugger


I'm working on project that simulates Twitter and I'm using HTML + JS on client and WCF services on server side (ajax calls), and Neo4J as database.


For example:


in $(document).ready(function ()



there is DisplayTweets service call -> DisplayTweets(username)



function DisplayTweets(userName) {
$.ajax(
{
type: "GET", //GET or POST or PUT or DELETE verb
url: "http://ift.tt/1ytKNVI", // Location of the service
data: { userName: userName },
contentType: "application/json; charset=utf-8", // content type sent to server
dataType: "json",
processdata: true, //True or False
success: function (msg) //On Successfull service call
{
DisplayTweetsSucceeded(msg);
},
error: function () // When Service call fails
{
alert("DISPLAY TWEETS ERROR");
}
}
);
}


and then DisplayTweetsSucceeded(msg) where msg would be json array of users tweets



function DisplayTweetsSucceeded(result)
{
for (var i = 0; i < result.length; i++)
{
var tweet = JSON.parse(result[i]);

var id_tweet = tweet.id;
var content_tweet = tweet.content;
var r_count_tweet = tweet.r_count;

NewTweet(null, id_tweet, content_tweet, r_count_tweet);
}

}




Function NewTweet is used for dynamic generating of tweets.


Problem is when I first load html page, nothing shows up, neither when I load it multiple times again. It only shows when I go through Firebug, line by line.


I'm presuming that maybe getting data from database is slower, but I'm not sure and also have no idea how to solve this. Any help will be very much appreciated, thank you in advance!





Aucun commentaire:

Enregistrer un commentaire