Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8031987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:15:46+00:00 2026-06-05T01:15:46+00:00

I have method to update notification and when update it return number of notification

  • 0

I have method to update notification and when update it return number of notification and content of notification with 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 I receive I 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 the template file, then render it with 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 to build a template of content
I have a <div id="replacehere"> to replace my content here
I use $('#replacehere').replaceWith(html); to replace but it success when first request in 10s after
I see json data receive has a new content and number of notification has change but content not change.
How to change it when receive new content.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:15:48+00:00Added an answer on June 5, 2026 at 1:15 am

    Guess you need just use

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

    otherwise it will remove #replacehere div… and second request wont find it to put content in…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Method name update, this will be called depending on the boolean
In Ruby on Rails, I have an update method in a controller, that is
I have a method that attempts to update a sql server database in an
I have a problem with the logic of this code, XNA's Update Method is
I call window.location.reload(false) in a javascript method to update the page. I have additional
I have a database entry that I need to update. This method obviously doesn't
I have the following code in my post action method for Edit. JobCardService.Update(viewData.JobCard); var
I have a NSViewController subclass with a convenience method to return the window controller
I have this method: - (void)reloadMessages:(NSNotification *)notification { NSLog(@RECIEVED NEW MESSAGES TO MessagesRootViewController); //
I have a background thread and the thread calls some methods that update the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.