<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>AJax Plus - Tips and tutorial for Ajax</title>
	<link>http://www.ajaxplus.net</link>
	<description>All you need to know about Ajax</description>
	<pubDate>Fri, 07 Mar 2008 09:30:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>How to submit a form using post and Ajax?</title>
		<link>http://www.ajaxplus.net/2008/03/07/how-to-submit-a-form-using-post-and-ajax/</link>
		<comments>http://www.ajaxplus.net/2008/03/07/how-to-submit-a-form-using-post-and-ajax/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 09:30:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Ajax Tools]]></category>

		<guid isPermaLink="false">http://www.ajaxplus.net/2008/03/07/how-to-submit-a-form-using-post-and-ajax/</guid>
		<description><![CDATA[  Hi all,
This is a very simple, powerful and useful Ajax code  that lets you submit a form using Ajax and &#8216;post&#8217; method.
lets start with the form.
The most important thing is to give an ID to the form and then call to a Javascript function on submit.  We will have something like:
&#60;form action=&#8221;add_client.php&#8221; method=&#8221;post&#8221; id=&#8221;add_client&#8221;  [...] ]]></description>
			<content:encoded><![CDATA[<p> Hi all,</p>
<p>This is a very simple, powerful and useful Ajax code  that lets you submit a form using Ajax and &#8216;post&#8217; method.</p>
<p>lets start with the form.</p>
<p>The most important thing is to give an ID to the form and then call to a Javascript function on submit.  We will have something like:</p>
<p>&lt;form action=&#8221;add_client.php&#8221; method=&#8221;post&#8221; id=&#8221;add_client&#8221;  name=&#8221;add_client&#8221; onsubmit=&#8221;post_form(&#8217;add_client&#8217;); return false;&#8221;&gt;</p>
<p>&lt;input type=&#8221;text&#8221; name=&#8221;client_name&#8221; id=&#8221;client_name&#8221;&gt;</p>
<p>&lt;input type=&#8221;submit&#8221; value=&#8221;Add&#8221;&gt;</p>
<p>&lt;/form&gt;</p>
<p>So when you submit this form the script calls the post_form function and send the form&#8217;s id (in this case add_client).</p>
<p>Now on the Javascript we will use the zxml library</p>
<p>&lt;script type=&#8221;text/javascript&#8221; src=&#8221;zxml.js&#8221;&gt;&lt;/script&gt;</p>
<p>and we will create the function post_form:</p>
<p>function post_form(form_id){</p>
<p>var oForm = document.getElementById(form_id);<br />
var sBody = getRequestBody(oForm);<br />
var oXmlHttp = zXmlHttp.createRequest();<br />
oXmlHttp.open(&#8221;post&#8221;, oForm.action, true);<br />
oXmlHttp.setRequestHeader(&#8221;Content-Type&#8221;, &#8220;application/x-www-form-urlencoded&#8221;);<br />
oXmlHttp.onreadystatechange = function () {<br />
if (oXmlHttp.readyState == 4) {<br />
if (oXmlHttp.status == 200) {<br />
view(oXmlHttp.responseText,page_name,display_type,div_name,job_id,span_id);<br />
}<br />
else {<br />
view(&#8221;An error occurred: &#8221; + oXmlHttp.statusText);<br />
}<br />
}<br />
};<br />
oXmlHttp.send(sBody);<br />
}<br />
function getRequestBody(oForm) {<br />
var aParams = new Array();<br />
for (var i=0 ; i &lt; oForm.elements.length; i++) {<br />
var sParam = encodeURIComponent(oForm.elements[i].name);<br />
sParam += &#8220;=&#8221;;<br />
if(oForm.elements[i].checked){<br />
sParam += &#8220;1&#8243;;<br />
}<br />
else {<br />
sParam += encodeURIComponent(oForm.elements[i].value);<br />
}<br />
aParams.push(sParam);<br />
}<br />
//alert (aParams);<br />
return aParams.join(&#8221;&amp;&#8221;);<br />
}</p>
<p>}</p>
<p>post_form calls to getRequestBody that gets all the form&#8217;s elements and send it back. Then post_form will submit the form to the action location (add_client.php) in the php file you should create a script that connect to the db gets the new client name from the form and insert it. Then you can generates a confirmation message on the php file (something like: echo &#8220;Client has been added&#8221;;)</p>
<p>Now the post_form gets back the php message and we need to decide what to do with it. Lets create a div where the message will be displayed</p>
<p>&lt;div id=&#8221;messege&#8221;&gt;&lt;/dib&gt;</p>
<p>Now post_form calls to the function view and sends the php&#8217;s messege to it. So function view will looke like:</p>
<p>function view(sText){</p>
<p>var el = document.getElementById(&#8217;message&#8217;);<br />
el.innerHTML = sText;</p>
<p>}</p>
<p>that&#8217;s it&#8230; you submitted a form and got the results on the same page. Easy <img src='http://www.ajaxplus.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxplus.net/2008/03/07/how-to-submit-a-form-using-post-and-ajax/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Javascript element value</title>
		<link>http://www.ajaxplus.net/2008/03/07/javascript-element-value/</link>
		<comments>http://www.ajaxplus.net/2008/03/07/javascript-element-value/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 09:07:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.ajaxplus.net/2008/03/07/javascript-element-value/</guid>
		<description><![CDATA[  Hi all,
For beginners this could be helpful - How to get the value of each element in your page using Javascript?
Lets say you have &#60;div id=&#8221;newid&#8221;&#62;&#60;/div&#62;
use this:
var element_value = document.getElementById(&#38;quot;newid&#38;quot;).value;
Hope it helps!
 ]]></description>
			<content:encoded><![CDATA[<p> Hi all,</p>
<p>For beginners this could be helpful - How to get the value of each element in your page using Javascript?</p>
<p>Lets say you have &lt;div id=&#8221;newid&#8221;&gt;&lt;/div&gt;</p>
<p>use this:</p>
<p>var element_value = document.getElementById(&amp;quot;newid&amp;quot;).value;</p>
<p>Hope it helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxplus.net/2008/03/07/javascript-element-value/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Simple Ajax code</title>
		<link>http://www.ajaxplus.net/2008/02/23/simple-ajax-code/</link>
		<comments>http://www.ajaxplus.net/2008/02/23/simple-ajax-code/#comments</comments>
		<pubDate>Sat, 23 Feb 2008 18:32:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Ajax Tools]]></category>

		<guid isPermaLink="false">http://www.ajaxplus.net/2008/02/23/simple-ajax-code/</guid>
		<description><![CDATA[  Here is a sample code to use ajax:
Lets say you have a field that you want to update the db every time someone insert info there without refreshing the page or going to another page.
So the html will look like:
[code]
&#60;input type=&#8221;text&#8221; name=&#8221;field1&#8243; id=&#8221;field1&#8243; onchange=&#8221;update_field()&#8221;&#62;
[/code]
This is very basic input type.
Now to the javascript:
first we need [...] ]]></description>
			<content:encoded><![CDATA[<p> Here is a sample code to use ajax:</p>
<p>Lets say you have a field that you want to update the db every time someone insert info there without refreshing the page or going to another page.</p>
<p>So the html will look like:<br />
[code]</p>
<p>&lt;input type=&#8221;text&#8221; name=&#8221;field1&#8243; id=&#8221;field1&#8243; onchange=&#8221;update_field()&#8221;&gt;</p>
<p>[/code]</p>
<p>This is very basic input type.<br />
Now to the javascript:</p>
<p>first we need to call to the ajax libary:<br />
[code]&lt;script type=&#8221;text/javascript&#8221; src=&#8221;zxml.js&#8221;&gt;&lt;/script&gt;[/code]</p>
<p>now we will create the update_field() function:</p>
<p>[code]function update_field(){<br />
var field1 = document.getElementById(&#8221;field1&#8243;);<br />
var Str = &#8220;update.php?field=&#8221; + field1;<br />
var oXmlHttp = zXmlHttp.createRequest();<br />
oXmlHttp.open(&#8221;get&#8221;, Str , true);<br />
oXmlHttp.onreadystatechange = function () {</p>
<p>if (oXmlHttp.readyState == 4) {<br />
if (oXmlHttp.status == 200) {<br />
save_info(oXmlHttp.responseText);<br />
} else {<br />
save_info(&#8221;An error occurred: &#8221; + oXmlHttp.statusText); //statusText is not always accurate<br />
}<br />
}<br />
oXmlHttp.send(null);</p>
<p>}[/code]</p>
<p>on this function we send the value of the field to a php file. On update.php we will update the the db with some php code:</p>
<p>[code]<br />
$sql = &#8220;update tbl_field set field=$field&#8221;;<br />
[/code]</p>
<p>Now the php return a message we need to take it and dispaly it on a div. First we will create a div on the body section:</p>
<p>[code]&lt;div id=&#8221;php_message&#8221;&gt;&lt;/div&gt;[/code]</p>
<p>then we will create a function save_info that we are calling it from update_field() after the php sent 400 code status (meaning everthing is ok)</p>
<p>[code]<br />
function save_info(sText) {<br />
var php_message = document.getElementById(&#8221;php_message&#8221;);<br />
php_message.innerHTML = sText;}<br />
[/code]</p>
<p>and that&#8217;s it! easy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxplus.net/2008/02/23/simple-ajax-code/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Great ajax library</title>
		<link>http://www.ajaxplus.net/2008/02/22/great-ajax-library/</link>
		<comments>http://www.ajaxplus.net/2008/02/22/great-ajax-library/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 16:55:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Ajax Tools]]></category>

		<category><![CDATA[Ajax]]></category>

		<category><![CDATA[zxml]]></category>

		<guid isPermaLink="false">http://www.ajaxplus.net/?p=4</guid>
		<description><![CDATA[  I really don&#8217;t remember where I found it (so I can&#8217;t give credit) but this is a great ajax library that can help you a lot to develop ajax applications.
zxml.js
Enjoy&#8230;
 ]]></description>
			<content:encoded><![CDATA[<p> I really don&#8217;t remember where I found it (so I can&#8217;t give credit) but this is a great ajax library that can help you a lot to develop ajax applications.</p>
<p><a href="http://www.ajaxplus.net/wp-content/uploads/2008/02/zxml.js" title="zxml.js">zxml.js</a></p>
<p><a href="http://www.ajaxplus.net/wp-content/uploads/2008/02/zxml.js" title="zxml.js"></a>Enjoy&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxplus.net/2008/02/22/great-ajax-library/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ajax blog</title>
		<link>http://www.ajaxplus.net/2008/02/22/hello-world/</link>
		<comments>http://www.ajaxplus.net/2008/02/22/hello-world/#comments</comments>
		<pubDate>Fri, 22 Feb 2008 16:18:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Ajax Tools]]></category>

		<category><![CDATA[Ajax]]></category>

		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.ajaxplus.net/?p=1</guid>
		<description><![CDATA[  Hi everyone,
The aim of this blog is to help you develop a better ajax applications. If you need general help or you have problems with Javascript or css this is the place to ask. I am sure you will learn to love ajax as much as I do&#8230;
Enjoy the blog!
 ]]></description>
			<content:encoded><![CDATA[<p> Hi everyone,</p>
<p>The aim of this blog is to help you develop a better ajax applications. If you need general help or you have problems with Javascript or css this is the place to ask. I am sure you will learn to love ajax as much as I do&#8230;</p>
<p>Enjoy the blog!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxplus.net/2008/02/22/hello-world/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
