Home     |      Learn AJAX     |      Forum     |      Register     |      Submit Resource     |      Submit Article      |      Contact Us

Home AJAX-Tips
 

Building an Ajax Request Class

 

An Ajax request class is a smart functionality that you can add to your online application so that it could access important information and functions faster. It uses a basic call and return from the online application but pushes it further so that the function could interact with the application. Because this is going to be implemented in an asynchronous function, the return is basically another function that deals with the call. The new information could be tweaked by developers according to their preferences in order to build the application.


The simple Ajax request class goes like this:


req = ajaxRequest(url, function);


The code itself will reveal a lot of information how the said function will execute. The code has two parameters – URL and Function. The URL could be located inside the application or from an outside source. The URL target should contain data which will usually come in the form of XML.


The function is regarded as the callback function of the request class. As soon as the data is extracted, the written function will be executed. The function could be as simple as another target or a function that could interpret the data for other functions to consider.


Reusing the Function

An Ajax request class is a remarkable function since it can be spread around the application without any problem. It is practically a stand alone function that could be executed over and over again depending on the need of developers.


There are functions that are considered standalone but they are only functions as they only interact with the extracted data. The Ajax request class on the other hand is more than that – aside from a simple function, it comes with the needed data.


The beauty of Ajax request class during reuse is that the function could be interactive with another function. You should be able to “spread” a single data around the application which could be useful in some instances.


Additional Option in Ajax Request Class

As this function is used in Ajax, you can expect that the function could be asynchronous. But you do not have to limit this function in an asynchronous level. The Ajax request class could be transformed into a non-asynchronous function. When transformed, the function could be implemented even in simpler websites such as HTML. You will be able to use the function normally provided you transfer the request class to be in a non-asynchronous state.


In order to do that, use the “forceSend()” so that it could push the functions to the server side. Basically, you will be placing the Ajax request class inside the forceSend function so that it could push the application without waiting for further response from the application. Implementing this is a little bit tricky since it might not stop the fetching of data altogether. After all, you are still implementing an Ajax based function.


An Ajax request class is a very simple yet very powerful function that could be added in the application. Through proper implementation, developers should be able to increase the availability of data to ease data processing.



Read Next: Hibernate in GWT



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links