Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what are the advantages and disadvantages of making ajax calls using jquery? [closed]

Tags:

jquery

As jquery ajax calls makes life really cool without a page refresh... But still interested to know some of the advantages and disadvantages of making ajax calls with jquery....

As i am using ajax calls for all my Add,Edit and Delete operations in my website it works pretty well as of now... Still knowing about the disadvantages would make life easier during deployment....

like image 755
ACP Avatar asked Apr 06 '10 07:04

ACP


People also ask

What are the disadvantages of AJAX?

The disadvantages of AJAX are: - Search engines would not be able to index an AJAX application. - The server information can not be accessed within AJAX. - AJAX is not well integrated with any browser.

What is the advantage and disadvantage of jQuery?

Ease of use This is pretty much the main advantage of using JQuery, it is a lot more easy to use compared to standard javascript and other javascript libraries. Apart from simple syntax, it also requires much less lines of code to achieve the same feature in comparison.

Which is better jQuery or AJAX?

While JQuery is a library for better client-side web page development, AJAX is a technique of doing XMLHttpRequest to the server from the web page and sending/retrieving data used on a web page. AJAX can change data without reloading the web page. In other words, it implements partial server requests.


2 Answers

The best use of AJAX is where it is used to send small payloads. Here is a simple example.

I load a page that contains information about stock. It has graphs, charts, company information and it also displays the share-price. Every 30 seconds, I make an AJAX request that gets the updated share-price and changes it on the page.

Without AJAX, I might decide to refresh the entire page every 30 seconds, but with AJAX, I can just make a lightweight request to get the tiny bit of information I need.

Using AJAX to submit forms isn't always the best bet. Asides from not really giving you a clear advantage over posting the form normally, you break conventions such as browser history (although some browsers now include JavaScript "states" as pages in the history).

When using AJAX, you need to handle the task of telling the user if something has gone wrong. You can do this with jQuery by specifying what should happen on error, but many people forget to do this and the end user is blissfully unaware of any problem.

Other issues to watch out for are any JavaScript errors that may prevent your events from firing - or if JavaScript is disabled, in either case ensuring that the form can submit normally before you add the AJAX code is the safest option.

like image 147
Fenton Avatar answered Sep 30 '22 16:09

Fenton


PRO:

In many cases, related pages on a website consist of much content that is common between them. Using traditional methods, that content would have to be reloaded on every request. However, using Ajax, a web application can request only the content that needs to be updated, thus drastically reducing bandwidth usage and load time.

The use of asynchronous requests allows the client's Web browser UI to be more interactive and to respond quickly to inputs, and sections of pages can also be reloaded individually. Users may perceive the application to be faster or more responsive, even if the application has not changed on the server side.

The use of Ajax can reduce connections to the server, since scripts and style sheets only have to be requested once.[12]

State can be maintained throughout a Web site. JavaScript variables will persist because the main container page need not be reloaded.

CON:

> Owing to their dynamic nature, Ajax interfaces are often harder to develop when compared to static pages.

Pages dynamically created using successive Ajax requests do not automatically register themselves with the browser's history engine, so clicking the browser's "back" button may not return the user to an earlier state of the Ajax-enabled page, but may instead return them to the last full page visited before it. Workarounds include the use of invisible IFrames to trigger changes in the browser's history and changing the anchor portion of the URL (following a #) when Ajax is run and monitoring it for changes.

Dynamic web page updates also make it difficult for a user to bookmark a particular state of the application. Solutions to this problem exist, many of which use the URL fragment identifier (the portion of a URL after the '#') to keep track of, and allow users to return to, the application in a given state.

Because most web crawlers do not execute JavaScript code, publicly indexable web applications should provide an alternative means of accessing the content that would normally be retrieved with Ajax, to allow search engines to index it.

Any user whose browser does not support JavaScript or XMLHttpRequest, or simply has this functionality disabled, will not be able to properly use pages which depend on Ajax. Similarly, devices such as mobile phones, PDAs, and screen readers may not have support for the required technologies. Screen readers that are able to use Ajax may still not be able to properly read the dynamically generated content. The only way to let the user carry out functionality is to fall back to non-JavaScript methods. This can be achieved by making sure links and forms can be resolved properly and do not rely solely on Ajax. In JavaScript, form submission could then be halted with "return false".

The same origin policy prevents some Ajax techniques from being used across domains, although the W3C has a draft of the XMLHttpRequest object that would enable this functionality.

Like other web technologies, Ajax has its own set of vulnerabilities that developers must address. Developers familiar with other web technologies may have to learn new testing and coding methods to write secure Ajax applications.

Ajax-powered interfaces may dramatically increase the number of user-generated requests to web servers and their back-ends (databases, or other). This can lead to longer response times and/or additional hardware needs.

wikipedia.org

like image 28
jAndy Avatar answered Sep 30 '22 16:09

jAndy