Best way to update value on the client's page WITHOUT refreshing the page

Discussion in 'Programming' started by Fking, Oct 31, 2012.

  1. #1
    Ok the clients loads a page where he is given address to send electonic payment via client outside the browser.
    As soon as the server sees the deposited money, it should update clients balance on the page WITHOUT the need the user to refresh the page.

    What's the best way/technology to do that?
     
    Solved! View solution.
    Fking, Oct 31, 2012 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    AJAX.

    That said, how much more information you need depends on how much you already know, but if you know Javascript and whatever server-side language your site uses (ASP, PHP, whatever), playing in any AJAX tutorial will show you how easy it is.
     
    Rukbat, Nov 1, 2012 IP
  3. Fking

    Fking Active Member

    Messages:
    257
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    how long it can wait using AJAX?
    For example you load the site but send the money 10 mins later?
     
    Fking, Nov 1, 2012 IP
  4. trevopoli

    trevopoli Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #4
    You can do exactly what you're describing with AJAX, should be relatively easy to look it up.
     
    trevopoli, Nov 1, 2012 IP
  5. Fking

    Fking Active Member

    Messages:
    257
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    thank you
    that would be long poll function right?

    do we have time limitations of any sort?
     
    Fking, Nov 2, 2012 IP
  6. ggiindia

    ggiindia Greenhorn

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #6
    Is there any other alternative than using AJAX??
     
    ggiindia, Nov 2, 2012 IP
  7. #7
    You send the AJAX request. The server sends the response back to the browser when it has it. IOW, if the request is for a long database operation, it may respond in half an hour. If the request is for something that happens fast, it'll respond back fast.

    If the response takes very long, the browser will give the user a message that a script on the page is taking a long time. If the user goes away or closes the page after he sees that, he'll never see the response. And there's nothing you can do about that.

    It would be whatever code you write on the server. It can be anything from a simple echo statement to accessing another site and waiting hours for a response. You can return one character or thousands of rows from a database query or a huge graphic that the server creates. Anything that you can generate on the server and that falls within practical guidelines. (I wouldn't use it to return gigabytes of data, for instance.)

    Only as far as what the server can do. If you consider the user leaving your site before he sees a response (if the response takes a long time), that would be another limitation.

    Sure. It's like killing a fly. You can use a fly swatter. Or you can use a sledge hammer. Or you can use dynamite. The fly swatter (AJAX) is the best way of doing it.
     
    Rukbat, Nov 2, 2012 IP
  8. Fking

    Fking Active Member

    Messages:
    257
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #8
    Thank you for the great and detailed answer dude, appreciate ti! :)
     
    Fking, Nov 3, 2012 IP