XMLHTTPJSClass - JSON Class for Ajax Operations

added by ashishsarda99
8/3/2010 8:30:55 AM


In the development of Ajax application many times we may come across following issues. * Need to update multiple text boxes simultaneously. * Fill more that one dropdown lists. * Combination of text boxes, dropdown lists and div tags. * Calling different web pages and different webservices Means one event may lead to updating of many html elements. In such cases we will have to send Ajax request in a loop. Again for each request we will have to take care of timeouts and request failures. Here if data is static we can keep it on HTML page and using JavaScript can directly hide and show the contents. But if we have to use real time data and also choices of display vary according to choices of the user, in such case looping of Ajax request may not be a good idea. In this article we will discuss about XMLHTTPRequest object and JavaScript. We will develop a JavaScript class in which we can vary our choices and also be able to update multiple HTML contents. Also this class can be extended as per the requirements. We will first talk about class in JavaScript, there is no keyword called class in JavaScript but we can use function as a class.