2

how does Ajax work ? you make a call to a remote service and you register a callback. the remote service does its job and then it has data to return.

How does the service actually call into the client browser if no websockets are employed? is the browser cheating by polling on a separate client thread?

and what do websockets do differently ?

microwth
  • 1,016
  • 1
  • 14
  • 27
  • 2
    An AJAX call is like any browser request for an asset-- the difference is that since it was made from JavaScript, your code can pay attention to when the response is returned and do something with it (in a callback). It requires the browser to make the request to the server for data. Websockets are a different beast-- they setup a two-way open connection between the server and the client machine-- so the server can push down information _without an explicit request for that information from the browser_. Different from long polling. – Alexander Nied Jan 04 '17 at 14:00
  • 2
    Check this out maybe: http://stackoverflow.com/questions/10028770/in-what-situations-would-ajax-long-short-polling-be-preferred-over-html5-websock#answer-10029326 – Alexander Nied Jan 04 '17 at 14:00
  • 1
    Ajax is a single stream socket, where you write once and the web server responds once, over http. Web socket is like a regular dual multiplex socket, both can write and read but there's no defined protocol – Ruan Mendes Jan 04 '17 at 14:10
  • is Ajax the same as long polling? – microwth Jan 04 '17 at 20:02
  • You can implement long polling with Ajax – Ruan Mendes Jan 04 '17 at 21:48
  • is it short then? I mean does the browser at regular intervals poll and check for an answer by the server? if that is so, does it maintain a connection to the server or is it stateless? – microwth Jan 04 '17 at 21:59

0 Answers0