<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: AJAX example</title>
	<atom:link href="http://www.cyberactiva.com/2009/09/ajax-example/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cyberactiva.com/2009/09/ajax-example/</link>
	<description>Every day&#039;s life about programming and webmarketing</description>
	<lastBuildDate>Thu, 22 Jul 2010 06:02:18 +0200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Claudio Barba</title>
		<link>http://www.cyberactiva.com/2009/09/ajax-example/comment-page-1/#comment-3</link>
		<dc:creator>Claudio Barba</dc:creator>
		<pubDate>Wed, 30 Sep 2009 12:22:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.cyberactiva.com/?p=27#comment-3</guid>
		<description>To avoid the freezing of the browser, it is much better to use asyncronous calls.
This way, users can continue using your site while the ajax call is performed.

In the following example we perform an asyncronous call; in case of error, we show it in a specific div, otherwise, we redirect the user to another page:

&lt;blockquote&gt;
function submitForm(v1,v2,v3)  
{ 
    var xhr; 
    try {  xhr = new ActiveXObject(&#039;Msxml2.XMLHTTP&#039;);   }
    catch (e) 
    {
        try {   xhr = new ActiveXObject(&#039;Microsoft.XMLHTTP&#039;);    }
        catch (e2) 
        {
          try {  xhr = new XMLHttpRequest();     }
          catch (e3) {  xhr = false;   }
        }
     }
  
    xhr.onreadystatechange  = function()
    { 
         if(xhr.readyState  == 4)
         {
         
              if(xhr.status  == 200) 
                  document.location.href=&quot;step3_fr.php?prime=&quot; + xhr.responseText; 
              else 
                  document.myerrordiv.innerhtml =&quot;Error code &quot; + xhr.status;
         }
    }; 

   xhr.open(&quot;POST&quot;, &quot;./callquote.php&quot;,  true); 
   var str = &quot;chky=&quot;+v1+&quot;&amp;chkm=&quot;+v2+&quot;&amp;chkd=&quot;+v3; 
   xhr.send(str); 
} 
&lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<p>To avoid the freezing of the browser, it is much better to use asyncronous calls.<br />
This way, users can continue using your site while the ajax call is performed.</p>
<p>In the following example we perform an asyncronous call; in case of error, we show it in a specific div, otherwise, we redirect the user to another page:</p>
<blockquote><p>
function submitForm(v1,v2,v3)<br />
{<br />
    var xhr;<br />
    try {  xhr = new ActiveXObject(&#8217;Msxml2.XMLHTTP&#8217;);   }<br />
    catch (e)<br />
    {<br />
        try {   xhr = new ActiveXObject(&#8217;Microsoft.XMLHTTP&#8217;);    }<br />
        catch (e2)<br />
        {<br />
          try {  xhr = new XMLHttpRequest();     }<br />
          catch (e3) {  xhr = false;   }<br />
        }<br />
     }</p>
<p>    xhr.onreadystatechange  = function()<br />
    {<br />
         if(xhr.readyState  == 4)<br />
         {</p>
<p>              if(xhr.status  == 200)<br />
                  document.location.href=&#8221;step3_fr.php?prime=&#8221; + xhr.responseText;<br />
              else<br />
                  document.myerrordiv.innerhtml =&#8221;Error code &#8221; + xhr.status;<br />
         }<br />
    }; </p>
<p>   xhr.open(&#8221;POST&#8221;, &#8220;./callquote.php&#8221;,  true);<br />
   var str = &#8220;chky=&#8221;+v1+&#8221;&#038;chkm=&#8221;+v2+&#8221;&#038;chkd=&#8221;+v3;<br />
   xhr.send(str);<br />
}
</p></blockquote>
]]></content:encoded>
	</item>
</channel>
</rss>
