Opt out of website AJAX

What are the things to consider and watch out for when building a website using AJAX? Should you take care of conditions like timeouts, error handling?

Best practics? What parameters should be considered when designing and coding?

+2


a source to share


3 answers


There are several different views:

AJAXs Framework

  • There are a few out there - I'm afraid I haven't used much, but they cover a lot of plumbing for you and handle X browser compatibility issues.
  • jQuery is very commonly used (which is probably useful for your resume).
  • ASP.NET AJAX if you are on MS platform.
  • Rolling can be enlightening, but you only want to do it for the right reasons.

dependencies

  • Which browsers will use the site and what they support, all the old JavaScript compatibility issues with the X browser apply.
  • A good structure should help here.
  • Be careful how you manage dependencies between client-side and server-side code; you want to ensure consistency as much as possible, and you want to avoid hardcoding and baking in other trash that will do maintenance over time and change a lot.

API / interface design



Safety

  • Publishing AJAX APIs on the web has its own set of security, but be careful about them.
  • Don't trust the user / system input, make sure you check all the calls made.
  • Don't forget that you can protect your API (or parts of it) in a secure area of ​​the site. Authenticated browsers will also be authenticated to use any AJAX interfaces secured in this way.

Documentation

  • AJAX by itself does not provide a way to describe itself (for example, via Web services via WSDL); I had a time where a server side interface provided information on how it should be called if it is not being called correctly or allow each interface to be called with a generic "Help" parameter - when called, it returns all the information you need to know. how to call it.
  • Your approach will depend on who can use / call the API: is it part of a web application that will only run on companies' local network, or is it related to puiblic / www?
+2


a source


I guess this is likely to be a joint tip, so here is one of my experiences.

One of the things I've found when working with AJAX and Internet Explorer is that IE sometimes likes to cache the response for your requests. So if you find that the requests work in Firefox but not IE, that might be the culprit.

Solution, just add an extra parameter to your request url, which will be completely irrelevant in most cases. The parameter can be whatever you want, but the value should be constantly changing and always different, the best solution I have found is to use a date / time stamp as the time is always increasing. For the visual learner, here's an example.

Normal request

http://example.com/controller/action?query=john

IE Job Requests



First request

http://example.com/controller/action?query=john&seed=1234567890

Second request

http://example.com/controller/action?query=john&seed=2345678901

The reason for this is that IE sees it as a new URI, which it never grabbed before it had nothing in it.

+2


a source


Maintaining user experience without JavaScript, also known as "progressive enhancement".

0


a source







All Articles