When is it appropriate to use AJAX?

前端 未结 8 1539
生来不讨喜
生来不讨喜 2021-01-06 09:24

When is it appropriate to use AJAX?
what are the pros and cons of using AJAX?

In response to my last question: some people seemed very adamant that I should only

8条回答
  •  [愿得一人]
    2021-01-06 09:57

    Ajax is primarily used when you want to reload part of a page without reposting all the information to the server.

    Cons:

    • More complicated than doing a normal post (working with different browsers, writing server side code to hadle partial postbacks)
    • Introduces potential security vulnerabilities ( You are introducing additional code that interacts with the server. This can be a problem on both the client and server.
      On the client, you need ways of sending and receiving responses. It's another way of interacting with the browser which means there is another point of entry that has to be guarded. Executing arbritary code, posting data to a non-intended source etc. There are several exploits for Ajax apps that have been plugged over time, but there will always be more. )

    Pros:

    • It looks flashier to end users
    • Allows a lot of information to be displayed on the page without having to load all at the same time
    • Page is more interactive.

提交回复
热议问题