p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Ajax 2nd Edition ISBN: 978-0-470-10949-6 (http://p2p.wrox.com/forumdisplay.php?f=310)
-   -   Chapter 4 - Prototype example. (http://p2p.wrox.com/showthread.php?t=93898)

pet2x December 6th, 2014 10:59 AM

Chapter 4 - Prototype example.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Prototype POST Example</title>
<script type="text/javascript"src="prototype.js"></script>
<script type="text/javascript">
function sendRequest() {
var oOptions = {
method: "post",
parameters: sBody,
onSuccess: function (oXHR, oJson) {
onFailure: function (oXHR, oJson) {
saveResult("An error occurred: " + oXHR.statusText);

var oRequest = new Ajax.Request("SaveCustomer.php", oOptions);

function saveResult(sMessage) {
var divStatus = document.getElementById("divStatus");
divStatus.innerHTML = "Request completed: " + sMessage;
<form method="post" action="SaveCustomer.php"
onsubmit="sendRequest(); return false">
<p>Enter customer information to be saved:</p>
<p>Customer Name: <input type="text" name="txtName" value="" /><br />
Address: <input type="text" name="txtAddress" value="" /><br />
City: <input type="text" name="txtCity" value="" /><br />
State: <input type="text" name="txtState" value="" /><br />
Zip Code: <input type="text" name="txtZipCode" value="" /><br />
Phone: <input type="text" name="txtPhone" value="" /><br />
E-mail: <input type="text" name="txtEmail" value="" /></p>
<p><input type="submit" value="Save Customer Info" /></p>
<div id="divStatus"></div>

Why is this not working for me? I try this your code on my computer, it takes me to the process page save customer.php.
Please why is the ajax.request function not working.

All times are GMT -4. The time now is 09:47 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.