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 6988857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:08:09+00:00 2026-05-27T19:08:09+00:00

This has been implemented in many websites lets say odesk or so.What I am

  • 0

This has been implemented in many websites lets say odesk or so.What I am thinking is Implement a message sending scheme which notifies the user that they have received message.

for example

You send message to me and I would be shown message Red icon from green. Obviously we would need a database table to store sender id receiver Id and so on but how do we implement it in such a way that user does not need to hit refresh button.

I am new to web from c# background so do not know as many ways.

I am developing it in Yii. Few suggestions would be great

  • 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-05-27T19:08:09+00:00Added an answer on May 27, 2026 at 7:08 pm

    You can do this by using a simple periodic refresh javascript method.

    Something like this in the view that has the message indicator:

    <?php Yii::app()->clientScript->registerScript('autoupdate-div-inbox-update',
                "setInterval(function(){
                    // do an ajax call to server to check for new messages
                    // using jquery's ajax method
                    $.ajax({
                        url: 'http://example.com/index.php?r=controller/action',// this is the url that will check for new messages for the current user
                        success: function(data) {// data is the data returned from the server
                            if(data){
                                // update your new message div
                                // you can show your red icon here
                            }
                        }
                    });
                    return false;
                 },1000);"
          );
    ?>
    

    So what is happening is that the setInterval method executes the function every 1000 milliseconds and the function checks for new messages using ajax.

    If you don’t know ajax in yii, then check the following for the controller action:

    public function actionMessages(){
        // check for new messages in the db
        $xyz = checkMessage();
        // assuming checkMessage returns the number of new messages if any or false if none
        // whatever we echo will be available to the javascript we wrote in the data variable
        echo $xyz;
    }
    

    Read more about the timing methods in javascript.

    This pattern is also called polling, there are also other popular methods like long polling, and server push, which i’m not very familiar with, but you should check them out too before deciding on a pattern.

    Hope this helps, ask for clarifications, if any.

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

Sidebar

Related Questions

I know this has been asked many times, and answered many times, but, all
This has been a rather problematic issue on numerous occasions. We have alot of
This has been driving me crazy for the past few minutes I have a
This has been one of the biggest obstacles in teaching new people ColdFusion. When
This has been driving me nuts. I keep getting the following exception System.InvalidOperationException: The
This has been driving me nuts. I hope it's not been asked before but
This has been bothering me lately- when I use some code like below to
This has been bugging me for more than two days now, so i thought
This has been annoying me for a while in several XCode projects. I really
This has been introduced in C# 4.0, but is there a way to achieve

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.