How to send response from server without any request from client

Discussion in 'PHP' started by viron86, Jan 22, 2011.

  1. #1
    hi

    Is it possible to send respone to client without client sending any request to server.
    Something that what i have seen on facebook where popup comes at the bottom of facebook page whenever someone likes or comments on my post.

    Thanks
     
    viron86, Jan 22, 2011 IP
  2. shofstetter

    shofstetter Well-Known Member

    Messages:
    178
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    120
    #2
    shofstetter, Jan 22, 2011 IP
  3. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #3
    as shofstetter told, you can do it with AJAX. It's easy to use & you can refresh it each 5 seconds. HOWEVER, it's client-side proccessing, so client is always requesting ;)
     
    G3n3s!s, Jan 22, 2011 IP
  4. viron86

    viron86 Active Member

    Messages:
    426
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #4
    it means i need to send request every time to check for the updates
     
    viron86, Jan 26, 2011 IP
  5. shofstetter

    shofstetter Well-Known Member

    Messages:
    178
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    120
    #5
    It does not require as much data to be sent as it would take to reload an entire page.
    In your page you would have javscript ask the server if there is anything new. the server responds(yes,no,whatever). I
    f the client gets a response stating there is something new. The client can send a request to get it.
    All of this happens in the background without the page reloading. Because the client is just requesting a status unless something has changed the load is very minimal, and far less than refreshing an entire page as the client is only requesting what it needs.

    If you need help coding something like this just send me a PM.
     
    shofstetter, Jan 26, 2011 IP
  6. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #6
    yep, there are no other ways how to do it another way. However, I can make script for you for small fee, PM me if you're interested
     
    G3n3s!s, Jan 26, 2011 IP
  7. spaceman12

    spaceman12 Active Member

    Messages:
    60
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    63
    #7
    yes, you can do it using AJAX technique. This is how it works:

    someone at the other end comented/liked ur post. Then, the effect gets updated into the database of the fb immediately, at the same time calling in the AJAX function (from the other end) in such a way as to reflect the change in the html content associated with ur account and only.

    NOTE: the user at the other end always triger the event though U remained stand still.

    P.S.
    I Can help u too :)
     
    spaceman12, Jan 26, 2011 IP
  8. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #8
    Sorry, but this is wrong answer. FB calls their AJAX each X seonds, not if someone posts reply to your comment or so ... It's user-side calling so YOUR clIeNT has to check it first.
     
    G3n3s!s, Jan 27, 2011 IP
  9. spaceman12

    spaceman12 Active Member

    Messages:
    60
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    63
    #9
    @G3n3
    lol....dont be a funny dude by teling me bak tht im wrong?.where the fuck did i goes wrong? Ur conception that fb calls in AJAX evrey second or sm will eventually crush down the whole server within mins with thos multi millions users online though ur theory can stil be made aplicable to relatively smaller sites.

    I repeat: the user who commented/post always triger the calls to AJAX and not necessarily tha the AJAX is set to auto refresh mode.
     
    spaceman12, Jan 27, 2011 IP
  10. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #10
    not each second ... each 10 seconds for example... Seriously. How would you tell something to client without client request? Client has to request data via AJAX so server response.
     
    G3n3s!s, Jan 27, 2011 IP