<?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>www.kevincornwell.com &#187; AJAX</title>
	<atom:link href="http://www.kevincornwell.com/blog/index.php/category/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kevincornwell.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 02 Dec 2010 16:31:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.2</generator>
		<item>
		<title>Comet &#8211; High Speed AJAX</title>
		<link>http://www.kevincornwell.com/blog/index.php/comet-high-speed-ajax/</link>
		<comments>http://www.kevincornwell.com/blog/index.php/comet-high-speed-ajax/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 18:04:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.kevincornwell.com/blog/index.php/comet-high-speed-ajax/</guid>
		<description><![CDATA[Basic Definitions of Comet: Wiki Server Technologies: IE will not allow your to read xmlhttp.responseText untill xmlhttp.readyState = 4 (complete &#8212; connection closed). It works in FF. var http_request = false; function makeRequest&#40;url&#41; &#123; http_request = false; if &#40;window.XMLHttpRequest&#41; &#123; // Mozilla, Safari,... http_request = new XMLHttpRequest&#40;&#41;; if &#40;http_request.overrideMimeType&#41; &#123; http_request.overrideMimeType&#40;'text/xml'&#41;; // See note below [...]]]></description>
			<content:encoded><![CDATA[<p>Basic Definitions of Comet:<br />
<a href="http://en.wikipedia.org/wiki/Comet_%28programming%29">Wiki</a></p>
<p>Server Technologies:</p>
<p>IE will not allow your to read xmlhttp.responseText untill xmlhttp.readyState = 4 (complete &#8212; connection closed).  It works in FF.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> http_request = <span style="color: #003366; font-weight: bold;">false</span>;  
<span style="color: #003366; font-weight: bold;">function</span> makeRequest<span style="color: #66cc66;">&#40;</span>url<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
 	http_request = <span style="color: #003366; font-weight: bold;">false</span>;
 	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>window.<span style="color: #006600;">XMLHttpRequest</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #009900; font-style: italic;">// Mozilla, Safari,...</span>
 		http_request = <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>http_request.<span style="color: #006600;">overrideMimeType</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
 			http_request.<span style="color: #006600;">overrideMimeType</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'text/xml'</span><span style="color: #66cc66;">&#41;</span>;
 			<span style="color: #009900; font-style: italic;">// See note below about this line</span>
 		<span style="color: #66cc66;">&#125;</span>
 	<span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>window.<span style="color: #006600;">ActiveXObject</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #009900; font-style: italic;">// IE</span>
 		<span style="color: #000066; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #009900; font-style: italic;">//</span>
			http_request = <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;Msxml2.XMLHTTP&quot;</span><span style="color: #66cc66;">&#41;</span>;
        		http_request = <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #66cc66;">&#41;</span>;
 		<span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span>e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
 			<span style="color: #000066; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
 				http_request = <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #66cc66;">&#41;</span>;
 			<span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span>e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span> 		<span style="color: #66cc66;">&#125;</span>
 	<span style="color: #66cc66;">&#125;</span>
 	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>!http_request<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
 		<span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'Giving up :( Cannot create an XMLHTTP instance'</span><span style="color: #66cc66;">&#41;</span>;
 		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;
 	<span style="color: #66cc66;">&#125;</span>
 	http_request.<span style="color: #006600;">onreadystatechange</span> = alertContents;
 	http_request.<span style="color: #000066;">open</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'GET'</span>, url, <span style="color: #003366; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
 	http_request.<span style="color: #006600;">send</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">var</span> i = <span style="color: #CC0000;">0</span>; <span style="color: #003366; font-weight: bold;">var</span> str = <span style="color: #3366CC;">&quot;&quot;</span>;
  <span style="color: #003366; font-weight: bold;">function</span> alertContents<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
 	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'info'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">innerHTML</span> = <span style="color: #3366CC;">'&lt;h3&gt;'</span>+ Date<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #3366CC;">' '</span> + http_request.<span style="color: #006600;">readyState</span> +<span style="color: #3366CC;">':&lt;/h3&gt;'</span> + http_request.<span style="color: #006600;">responseText</span>;
 	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>http_request.<span style="color: #006600;">readyState</span> == <span style="color: #CC0000;">4</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
 		$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'info'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">innerHTML</span> = <span style="color: #3366CC;">'&lt;h1&gt;Complete ('</span>+ http_request.<span style="color: #000066;">status</span> +<span style="color: #3366CC;">'):&lt;/h1&gt;'</span> + http_request.<span style="color: #006600;">responseText</span>;
 	<span style="color: #66cc66;">&#125;</span>
 <span style="color: #66cc66;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">function</span> $<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
     <span style="color: #003366; font-weight: bold;">var</span> elements = <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
     <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i = <span style="color: #CC0000;">0</span>; i &lt; arguments.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
       <span style="color: #003366; font-weight: bold;">var</span> element = arguments<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;
       <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> element == <span style="color: #3366CC;">'string'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
         <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>document.<span style="color: #006600;">getElementById</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
           element = document.<span style="color: #006600;">getElementById</span><span style="color: #66cc66;">&#40;</span>element<span style="color: #66cc66;">&#41;</span>;
         <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>document.<span style="color: #006600;">all</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
           element = document.<span style="color: #006600;">all</span><span style="color: #66cc66;">&#91;</span>element<span style="color: #66cc66;">&#93;</span>;
         <span style="color: #66cc66;">&#125;</span>
       <span style="color: #66cc66;">&#125;</span>
       elements.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span>element<span style="color: #66cc66;">&#41;</span>;
     <span style="color: #66cc66;">&#125;</span>
     <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>arguments.<span style="color: #006600;">length</span> == <span style="color: #CC0000;">1</span> &amp;&amp; elements.<span style="color: #006600;">length</span> &gt; <span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
       <span style="color: #000066; font-weight: bold;">return</span> elements<span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#93;</span>;
     <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span>
       <span style="color: #000066; font-weight: bold;">return</span> elements;
     <span style="color: #66cc66;">&#125;</span>
 <span style="color: #66cc66;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> go<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> 	makeRequest<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'http://www.kevincornwell.com/comet/x-mixed-replace.php'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.kevincornwell.com/blog/index.php/comet-high-speed-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

