<div id="whole">
<div>First Name: <input type="text" id="first" value="creatersite"></div> <br />
<div>Last Name: <input type="text" id="last" value="Web Developer"></div> <br />
<div align="center"><input type="button" value="submit" onClick="doAjaxPost()"></div>
</div>
Script:
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script>
function doAjaxPost() {
// get the form values
var field_a = $('#first').val();
var field_b = $('#last').val();
$.ajax({
type: "POST",
url: "serverscript.php",
data: "firstname="+field_a+"&lastname="+field_b,
success: function(resp){
// we have the response
alert("Server said:\n '" + resp + "'");
},
error: function(e){
alert('Error: ' + e);
}
});
}
</script>
No comments:
Post a Comment