0

This is something I was wondering, but could not get a definitive answer elsewhere.

Is a http get request asynchronous? If they're different, are there any major differences?

Not looking for opinions, just definitive answers. Googling has just repeatedly led me to examples of one or the other.

Oisín Foley
  • 2,317
  • 2
  • 22
  • 29
  • Do you mean the literal difference between AJAX and HTTP verbs? Or do you mean the difference between `$.ajax()`, `$.get()` etc? The long story short is that AJAX is an asynchronous way of performing a GET. – Inspector Squirrel Jul 17 '15 at 11:42

3 Answers3

0

HTTP is the most common protocol used to transfer data on the web. It's what the browser users on port 80 for all websites. Pages, AJAX, etc.

GET is a particular "verb" used in an HTTP request. A GET request is usually distinct in that it doesn't have a request body and it doesn't expect to modify anything on the server, simply "get" data.

AJAX requests are essentially HTTP requests made from JavaScript code, rather than from navigation in the browser. They may be GET requests, or they may be other kinds of HTTP requests. Structurally they're no different from any other HTTP request made by the browser, they're just made from code instead of the browser's UI.


There is overlap between these three terms, because they're not mutually exclusive versions of the same thing. They're apples and oranges, really. HTTP isn't different from the other two, it would be different from something like FTP. GET isn't different from the other two, it would be different from something like POST.

You can see a lot of this in action by taking a look at your browser's debugging tools. Visiting any reasonably active page (such as Stack Overflow, for example) will show you a number of requests being made and the server's responses to those requests. As you interact with a page which uses AJAX, watch those requests in the debugging tools and see how they're structured. Load a page or two by navigation and see how those requests are structured.

There's not much to it, really. It's all requests and responses, each of which is simply headers and content.

David
  • 208,112
  • 36
  • 198
  • 279
  • Thanks for answering, this explained a few things, was mainly just looking for the subtle differences, which this explained. – Oisín Foley Jul 17 '15 at 14:07
0

Ajax used so web applications can send data to and retrieve from a server asynchronously (in the background) without interfering with the display and behavior of the existing page.

HTTP GET or HTTP POST are method in the HTTP Protocol, which are a way to send and receive the data.

While Ajax is the Car, HTTP Protocol is the Driving laws.

Few examples of everyday surfing using Ajax:

  • Facebook Feed - When scrolling to the bottom of Facebook a Loader circle appears that loads a more prior updates on your wall, this is happening without surfing to another page, but rather retrieving it while still on the same page.

  • Google Omnibox Prediction - When typing part of the text in the Omnibox, google will suggest you the completion of your text while you're still typing.

Orel Eraki
  • 11,940
  • 3
  • 28
  • 36
0

First try to get through : GET vs POST.

An ajax call can be GET or POST or PUT or any other.

To differentiate between ajax GET & normal HTTP GET.

  1. Ajax GET seems asynchronous by as the request is sent using another thread by the browser.
  2. Ajax GET request has additional X-Requested-With: XMLHttpRequest.
  3. GET Request is captured by browser history, whilw Ajax GET does not get captured.
Community
  • 1
  • 1
Parimal Raj
  • 20,189
  • 9
  • 73
  • 110