Prev | Current Page 66 | Next

Larry Ullman

"Building a Web Site with Ajax: Visual QuickProject Guide"

??™;
72 adding records via Ajax
complete the XML
1 The fi rst else clause applies
if the query did not result in one
a?¬? ected row. A syntax error
would typically be the cause.
(See extra bits on page 84.)
??¦
echo ???The employee has been added.result>??™;
} else { // Query failure.
echo ???The employee could not be added due
to a system error.

???;
}
} else { // Errors!
echo ???Please correct problems with the
highlighted field(s) below.

???;
}
2 The second else clause
applies if the data didn??™t
pass all the validation tests.
adding records via Ajax 73
3 For both else clauses, an appropriately
descriptive message is included in the XML
output, within an element called result.
4 Close the root XML element to complete
the XML output. No need to use closing
HTML tags!
mysql_close($dbc);
echo ?????™;
?>
complete the XML (cont.)
74 adding records via Ajax
handle the response
The PHP page sends back XML data, which must be handled by
the JavaScript. Add this new function to the add_employee.js
JavaScript fi le.


Pages:
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78