javascript - notification update when receive ajax respone -


i have method update notification , when update return number of notification , content of notification json type

{     "friend_request": 4,     "request": [{         "user_id": "1",         "picture": "/home/sepdau/",         "name": "le chanh"},     {         "user_id": "2",         "picture": "",         "name": "yii php"},     {         "user_id": "4",         "picture": "13366396884.jpg",         "name": "minh le"},     {         "user_id": "11",         "picture": "",         "name": "thang phan"}] }​ 

when receive update number of notification success

function updatenotification(){             $.ajax({         url: '/nevergiveup/index.php/site/updatenotification',         type: "post",         datatype: "json",         success: function(data){                         if(data.friend_request>0){                 $(".zingcounter").text(data.friend_request); //update number of nofitcation                 // load template file, render data                 var html = new ejs({url: '/nevergiveup/jstemplates/friend_request.ejs'}).render(data);                 //$("#frlist").append(html);                 //$(html).replaceall('#replacehere');                 $('#replacehere').replacewith(html); // update content of notification             }              settimeout(updatenotification,10000);         },         error: function(){             settimeout(updatenotification,10000);         }     });        } 

i use ejs build template of content
have <div id="replacehere"> replace content here
use $('#replacehere').replacewith(html); replace success when first request in 10s after
see json data receive has new content , number of notification has change content not change.
how change when receive new content.

guess need use

$('#replacehere').html(html); 

otherwise remove #replacehere div... , second request wont find put content in...


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -