2

Since I am new to web development, I am confused about the difference between 'ajax' and 'http' request. What's the difference between those two and are they on the same par?

3
  • 2
    In short, ajax makes a http request and while it is waiting for it to return, uses javascript to make it look like it's doing something. So ajax is something that uses http Commented Feb 17, 2019 at 12:28
  • @Nick.McDermaid Would it be easier for me to think that either one of those falls under the category of another? Commented Feb 17, 2019 at 12:36
  • 1
    Yes. Ajax=JavaScript + HTTP. Commented Feb 17, 2019 at 13:07

2 Answers 2

4

I know this is an old question, but I'll type this down anyway for anyone who comes across.

Simply put, HTTP is the protocol (procedure of communication) that both the web server and the web browser understand. With both AJAX and non-AJAX requests, the browser sends HTTP requests and receives HTTP responses from the web server.

Deference between an AJAX request and a non-AJAX request is that, AJAX requests:

  • work in the background seamlessly, and
  • don't make the pages to reload every time a response is received.

while the non-AJAX requests load/reload the web page every time a response is received.

Sign up to request clarification or add additional context in comments.

Comments

1

jQuery's ajax() sends the data with Content-type: x-www-form-urlencoded

Angular's $http sends the data with Content-type: application/json

Your server obviously expects JSON, but you set up the $.ajax() call incorrectly for that

  1. The method property doesn't seem to exist.
  2. The type property is supposed to determine the type of the request (e.g. 'GET', 'POST' etc).
  3. In order to change the default content-type to application/json you can use the contentType property.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.