1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Rep Power

    Handling connection issues in ajax applications

    I've made a 1-page chess application where the whole application runs as javascript and uses http POST request to store and retrieve the game data. The application runs quite well in general, but this is under conditions where the connections do not fail.

    For example i send post requests to the server to store a player's move. However, how do I know if the move was actually stored? Is there a common way in handling those issues? Maybe using timeouts and make the requests to the server idempotent so that if it happens twice it doesnt matter? And then more of a practical question. Is there an easy way to listen for thiose timeouts in javascript or jquery?

    If I let my application run for a long time while it is checking if the opponent makes a move, then once in a while it gives an error "POST failed" or something similar, and it refers to a line in jquery. Is that caused by connection issues?

    I have no experience in asynchronous applications whatsoever so any tips are welcome.

  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Jakarta, Indonesia.
    Rep Power
    Many would suggest Firebug; it's an AddOn for Firefox.

    I myself am too lazy to learn it though, so I usually rely on Firefox's "Web-Console" to monitor any AJAX requests/responses. I think it's has been a built-in tool since version 21???

    To activate it just press the <Ctrl-Shift-K>. When you also need to see what's being sent/received, just right-click on the first AJAX line in the console and make sure to put checkmark on "Log request/ response body" menu item.

    Hope this helps, good luck!
    Last edited by hdewantara; December 21st, 2013 at 03:28 AM.

IMN logo majestic logo threadwatch logo seochat tools logo