What are the cases when AJAX should not be used?

Sites and applications using AJAX appear to be growing rapidly. And probably one of the main reasons for using AJAX is to improve user experience. My concern is that just because the CAN project uses AJAX does not mean that it MUST.

Perhaps AJAX exposes more security threats to the site / application for the sake of UX. You may have other reasons not to use AJAX.

When should you avoid using AJAX?

+4
source share
8 answers

Getting data is already available or data is easily accessible

I usually see that on car sites where there are models and models. Their usual <select> (without JavaScript) includes <optgroup> as such:

 <select> <optgroup label="Ford"> <option value="21">Escape</option> <option value="21">F-150</option> </optgroup> <optgroup label="Toyota"> <option value="51">Corolla</option> <option value="52">Yaris</option> </optgroup> </select> 

Then usually hide this <select> and create 2 new options, one for make and one for models.

All is well before that. They start to mess up here.

Then they process the server request to get the make list, and then run another request to get the list of models, when they could just parse the source element, try to get their information. Then, every time you change make, another request is executed ...

The above example is a great example of when NOT to use AJAX. Consider this: a query is longer than an analysis of the available data, so it makes the user wait. They probably query their database every time, so it has the advantage of using their central processor. And it requires more bandwidth. A terrible waste of resources.

What they had to do

They should simply parse the DOM try under <select> to get the relevant information. Each <optgroup> is an element in make <select> , and each <option> of <optgroup> is an element in <select> models.

Other examples

  • Using AJAX for simple static modifications of the DOM (in most cases, you do not need AJAX to switch from one tab to another, just include the data in the original request).
  • Using AJAX to retrieve data at boot (why not include it with the original request?)
  • Using AJAX for an image gallery (why not include images and manipulate them after completing a request?)
+4
source

You should definitely avoid AJAX if you are sure that your clients will use browsers that do not support javascript,

+3
source

In fact, AJAX should be used to improve user experience. If not, then Flash or whatever you have.

Naturally, if there is no possible improvement, there is no reason to go this way. I mark this as unlikely. If you find such an event, the blog post about it: it will probably make reading interesting.

There are situations when AJAX is contraindicated. Basically, when you do not have people using the site. If you expect the site to work with SOFTWARE, a query manager, you should make sure that it works fine without AJAX.

And if you do not expect the software to manage requests, I hope you have an alternative API for it that can do everything the site can do. Otherwise, you are simply fooling yourself and enduring your customers.

+3
source

If your development time is limited or your team lacks sufficient experience, you can make a good example in order not to get into AJAX programming.

But otherwise :

[AJAX calls] are no more or less secure than a normal HTTP POST request by a browser, as from -form -.

The "fix" for this is the same "fix", for requests without AJAX - use SSL.

+1
source

I hear this a lot - just because you can do it pretty with Ajax, that doesn't mean you should.

I do not think you should definitely put the UI on the backburner. This should not be the last thing you think about, especially in some cases.

The user interface is what the user sees - they do not see any complexity behind him, so they will judge the quality of your site / application based on how easy it is to use and how it makes sense to them.

With that in mind, choose Ajax based on your user perspective. Does it make sense that when I click on this button, the page slides to the left to open a new section? Will it comfort me or embarrass me so that the page is grayed out and the "Workers ..." image is displayed in front?

+1
source

When redirecting a user to a new page that the user may want to bookmark, i.e. if clicking on the link causes the content to be updated using AJAX, the user cannot add bookmarks to the page.

+1
source

AJAX should be avoided if the same functionality can be fully implemented on the client side without additional return to the server.

For example, it might be more efficient to sow a client with a list of zip codes for all US states and select the zip code size in the appropriate set, rather than go to the server for a list of valid zip codes for this state.

+1
source

Perhaps AJAX exposes more security threats to the site / application for the sake of UX. You may have other reasons not to use AJAX.

How? What are security threats?

0
source

All Articles