<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Geek is a lifestyle &#187; AJAX</title>
	<atom:link href="http://blog.amanjain.com/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.amanjain.com</link>
	<description>Aman's Blog</description>
	<lastBuildDate>Wed, 06 Jan 2010 10:47:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simple AJAX optimization</title>
		<link>http://blog.amanjain.com/2008/12/simple-ajax-optimization/</link>
		<comments>http://blog.amanjain.com/2008/12/simple-ajax-optimization/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 14:09:36 +0000</pubDate>
		<dc:creator>Aman</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.amanjain.com/?p=113</guid>
		<description><![CDATA[When ever we write an ajax code to create the AJAX objectwe tend to do it like:
function createAjaxObject()
{
if(window.XMLHttpRequest)
{
ajaxObject =  new XMLHttpRequest();
return ajaxObject;
}
else if(window.ActiveXObject)
{
ajaxObject = new ActiveXObject(&#8221;Microsoft.XMLHTTP&#8221;);
return ajaxObject;
}
else if(document.ActiveXObject)
{
ajaxObject = new ActiveXObject(&#8221;Msxml2.XMLHTTP&#8221;);
reutrn ajaxObject;
}
else
{
return null ;
}
}
Now consider a situation when we need to make large no of AJAX calls, the whole loop is called multiple times, which [...]]]></description>
			<content:encoded><![CDATA[<p>When ever we write an ajax code to create the AJAX objectwe tend to do it like:</p>
<p>function createAjaxObject()<br />
{<br />
if(window.XMLHttpRequest)<br />
{<br />
ajaxObject =  new XMLHttpRequest();<br />
return ajaxObject;<br />
}<br />
else if(window.ActiveXObject)<br />
{<br />
ajaxObject = new ActiveXObject(&#8221;Microsoft.XMLHTTP&#8221;);<span id="more-113"></span><br />
return ajaxObject;<br />
}<br />
else if(document.ActiveXObject)<br />
{<br />
ajaxObject = new ActiveXObject(&#8221;Msxml2.XMLHTTP&#8221;);<br />
reutrn ajaxObject;<br />
}<br />
else<br />
{<br />
return null ;<br />
}</p>
<p>}</p>
<p>Now consider a situation when we need to make large no of AJAX calls, the whole loop is called multiple times, which is not required.</p>
<p>So what we can write is:</p>
<p>function createAjaxObject()<br />
{<br />
if(window.XMLHttpRequest)<br />
{<br />
createAjaxObject = function(){ return new XMLHttpRequest(); };<br />
}<br />
else if(window.ActiveXObject)<br />
{<br />
createAjaxObject = function(){ return new ActiveXObject(&#8221;Microsoft.XMLHTTP&#8221;); };<br />
}<br />
else if(document.ActiveXObject)<br />
{<br />
createAjaxObject = function(){ return new ActiveXObject(&#8221;Msxml2.XMLHTTP&#8221;); };<br />
}<br />
else<br />
{<br />
createAjaxObject = function(){ return null ;};<br />
}<br />
return createAjaxObject();<br />
}</p>
<p>If we do this it will rewrite the function after it is first called with the most suitable object it can handel.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.amanjain.com/2008/12/simple-ajax-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
