Difference between AJAX request and a regular browser request

后端 未结 6 1774
予麋鹿
予麋鹿 2020-12-23 11:09

Is there a difference between an AJAX request and a direct browser request (in terms of how a web page is called and loaded)?

In other words, I mean: is a direct ser

6条回答
  •  忘掉有多难
    2020-12-23 11:32

    There may be some header differences, but the main behavior difference is on the client.

    When the browser makes a regular request as in window.location.href = "index.html", it clears the current window and loads the server response into the window.

    With an ajax request, the current window/document is unaffected and javascript code can examine the results of the request and do what it wants to with those results (insert HTML dynamically into the page, parse JSON and use it the page logic, parse XML, etc...).

    The server doesn't do anything different - it's just in how the client treats the response from the two requests.

提交回复
热议问题