Ajax with prototype

25th Jan 2010 at 5:39 AM | Posted in Ajax wid jquery&prototype | Leave a comment
var url = 'checkZip.php';
var params = 'zip=' + $F('zip'); //$F('zip')get the value of field zip
var ajax = new Ajax.Updater({success: 'zipResult'},
url,
{method: 'get', parameters: params, onFailure: reportError});
}
}
function reportError(request) {
$F('zipResult') = "Error";
}

The html is below:

<body>
<form>
<label for="zip">zip:</label>
<input type="text" name="zip" id="zip" onkeyup="checkZip();" />
<div id="zipResult"></div>
</form>
</body>

Get help from http://www.petefreitag.com/item/515.cfm

Advertisements

Call ajax using jquery

25th Jan 2010 at 3:33 AM | Posted in Ajax wid jquery&prototype | Leave a comment

Save some data to the server and notify the user once it’s complete.

Syntaxt is:

$.ajax({
   type: "POST",
   url: "some.php",//page where tha ajax call is made
   data: "name=John&location=Boston", //this data will be sent to some.php page
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
 });
(don't forget to include jquery.js file into your script)

Blog at WordPress.com.
Entries and comments feeds.