View Single Post
Old 12-05-2007, 05:05 PM   #2 (permalink)
Matt83
The Contributor
Upcoming Programmer 
 
Matt83's Avatar
 
Join Date: Oct 2007
Location: Argentina
Posts: 72
Thanks: 18
Matt83 is on a distinguished road
Default

I been playing recently with Protoype, so i thought as a good experience, to update this post with the alternative code needed to run the script with this Library.

First we need to make a modification to our index.html, we of course have to include the Prototype Library but also modify two values on our call to request_action:

index.html:

HTML Code:
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/ajax.js" type="text/javascript"></script>

<input id="email" name="email" type="text" />

<input id="subscribe" name="subscribe" type="button" onclick="request_action('suscribenews.php', 'add&email='+$('email').value, 'target')" value="Subscribe"/>
<input id="unsubscribe" name="unsubscribe" type="button" onclick="request_action('suscribenews.php', 'delete&email='+$('email').value, 'target')" value="Unsubscribe"/>

<div id="target"></div>
Once thats done we have to make another slightly change, but this time to ajax.js:

Code:
function request_action(jurl,jdata,jtarget)
{
	$(target).innerHTML = "Processing request...";
	var myAjax = new Ajax.Updater(jtarget, jurl, {	method: 'get',	parameters: jdata});
}
And thats it!, pretty simple and pretty similar. Hope you find it useful!
__________________
http://www.mattvarone.com
Matt83 is offline  
Reply With Quote
The Following User Says Thank You to Matt83 For This Useful Post:
webosb (01-24-2008)