<?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>Cyberactiva web development and optimisation &#187; Ajax</title>
	<atom:link href="http://www.cyberactiva.com/category/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cyberactiva.com</link>
	<description>Every day&#039;s life about programming and webmarketing</description>
	<lastBuildDate>Mon, 11 Apr 2011 05:15:34 +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>AJAX example</title>
		<link>http://www.cyberactiva.com/2009/09/ajax-example/</link>
		<comments>http://www.cyberactiva.com/2009/09/ajax-example/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 12:28:12 +0000</pubDate>
		<dc:creator>Claudio Barba</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.cyberactiva.com/?p=27</guid>
		<description><![CDATA[<p>There are tons of places on the net where you can find some ajax tutorial on how to make hidden calls to the server.
Anyway, I put here a basic javascript function (may be more for my reference). For instance I have to send three parameters v1,v2,v3 to the checkdate.php server page and receive back a [...]]]></description>
			<content:encoded><![CDATA[<p>There are tons of places on the net where you can find some ajax tutorial on how to make hidden calls to the server.<br />
Anyway, I put here a basic javascript function (may be more for my reference). For instance I have to send three parameters v1,v2,v3 to the checkdate.php server page and receive back a code. If the code is equal to 1, then I show the errors&#8217; layer and hide the buttons&#8217; layer.</p>
<blockquote><p>function ajaxsend (v1,v2,v3)<br />
{<br />
var xajax = null;</p>
<p>if(window.XMLHttpRequest) xajax = new XMLHttpRequest();<br />
else if(window.ActiveXObject) xajax = new ActiveXObject &#8220;Microsoft.XMLHTTP&#8221;);<br />
else return(false);</p>
<p>var str = &#8220;chky=&#8221;+v1+&#8221;&amp;chkm=&#8221;+v2+&#8221;&amp;chkd=&#8221;+v3;<br />
xajax.open(&#8221;POST&#8221;,&#8221;./checkdate.php&#8221;,false);<br />
xajax.setRequestHeader(&#8221;Content-Type&#8221;,&#8221;application/x-www-form-urlencoded&#8221;);<br />
xajax.send(str);</p>
<p>if(xajax.readyState == 4) {<br />
if (xajax.responseText==&#8221;1&#8243;) { //&lt;15years<br />
hide(&#8217;buttons&#8217;);<br />
show(&#8217;errors&#8217;);<br />
}<br />
}<br />
}</p></blockquote>
<p>Just to be complete, here are the two functions hide and show, written in a &#8220;browser independent&#8221; way:</p>
<blockquote><p>function show(layer_ref) {</p>
<p>if (document.all) { //IS IE 4 or 5 (or 6 beta)<br />
eval( &#8220;document.all.&#8221; + layer_ref + &#8220;.style.display = &#8216;block&#8217;&#8221;);<br />
}<br />
if (document.layers) { //IS NETSCAPE 4 or below<br />
document.layers[layer_ref].display = &#8216;block&#8217;;<br />
}<br />
if (document.getElementById &amp;&amp;!document.all) {<br />
mylayer = document.getElementById(layer_ref);<br />
mylayer.style.display = &#8216;block&#8217;;<br />
}<br />
}</p>
<p>function hide(layer_ref) {</p>
<p>if (document.all) { //IS IE 4 or 5 (or 6 beta)<br />
eval( &#8220;document.all.&#8221; + layer_ref + &#8220;.style.display = &#8216;none&#8217;&#8221;);<br />
}<br />
if (document.layers) { //IS NETSCAPE 4 or below<br />
document.layers[layer_ref].display = &#8216;none&#8217;;<br />
}<br />
if (document.getElementById &amp;&amp;!document.all) {<br />
mylayer = document.getElementById(layer_ref);<br />
mylayer.style.display = &#8216;none&#8217;;<br />
}<br />
}</p></blockquote>
<p>I hope you will find this example useful!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cyberactiva.com/2009/09/ajax-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

