MySQL, 258 <strong>PHP</strong>, 259 N int imagecolorat() function, <strong>AJAX</strong> chat, 163 Intellisense, Microsoft Visual Studio, 165 NOT NULL property, MySQL, 102 Internet Explorer security, 80 IRC client integration, <strong>AJAX</strong> chat, 145 O isDatabaseCleared() function, <strong>AJAX</strong> chat, 163 ob_clean() function, error h<strong>and</strong>ling, 77 J object detection, JavaScript, 45 Object Oriented Programming (OOP), 109 onclick event, <strong>AJAX</strong> Suggest <strong>and</strong> Java Virtual Machine, 13 Autocomplete, 184 JavaScript onkeyup event, <strong>AJAX</strong> Suggest <strong>and</strong> about, 12, 30 Autocomplete, 184 client-side uses, 30 onload event, 36 events, 33 onreadystatechange() method, repetitive functions, 91 XMLHttpRequest, 47 security, 79 OOP, 109 seperate js files, 31 open() method, XMLHttpRequest, 47 JavaScript <strong>and</strong> DOM application Opera security, 80 jsdom.html, 32 jsdom.js, 32 JavaScript events <strong>and</strong> DOM P morejsdom.html, 35 page caching, <strong>PHP</strong>, 90 morejsdom.js, 35, 36 page expiration header, proxyping.php, 90 JavaScript Object Notation, 16 JVM, 13 parameters passing, <strong>PHP</strong>, 71 <strong>PHP</strong> about, 12, 65 L code structure, 109 connecting to database, 105 loadGridPage() function, 220 DOM, 65 loadStylesheet() function, 219 error h<strong>and</strong>ling, 71 form validation, 123, 142 M JavaScript security, 79 manipulating data, MySQL, 104 Meebo, <strong>AJAX</strong> chat solution, 145 message queue, thread-safe <strong>AJAX</strong>, 125 MySQL about, 101 connecting to database, 105 creating database tables, 101 data manipulation, 104 DML comm<strong>and</strong>s, 104 indexes, 102 NOT NULL property, 102 phpMyAdmin, 103 primary key, 101 MySQL installation Unix, 261 Windows, 258 OOP, 109 page caching, 90 passing parameters, 71 proxy server script, 85 remote servers, 79 server-side uses, 30 working with MySQL, 101 <strong>PHP</strong> <strong>and</strong> MySQL application config.php, 107 create tables, 106 error_h<strong>and</strong>ler.php, 107 index.php, 107 populate tables, 106 <strong>PHP</strong> DOM, 65 <strong>PHP</strong> installation Unix, 262 Windows, 259 270 www.it-ebooks.info
<strong>PHP</strong> Parameters <strong>and</strong> Error H<strong>and</strong>ling realtime SVG charting error_h<strong>and</strong>ler.php, 74, 75, 76, 77 ajaxrequest.js, 194, 200 morephp.html, 72 chart.svg, 194, 200 morephp.js, 72 index.html, 193, 200 morephp.php, 74 realTimeChart.js, 201 <strong>PHP</strong>5 errors, 75 RealTimeChart.js, 195 phpMyAdmin svg_chart.php, 199 creating tables, 103 refreshXYIndexes() function, installation, 263 realTimeChart.js, 201 placeholders, 33 Relational Database Management Systems, postMessages() function, <strong>AJAX</strong> chat, 163 101 prediction, user input, 165 remote servers, connecting to preparing database, <strong>AJAX</strong>, 264 about, 79 primary key, MySQL, 101 Firefox, 83 private class members, 110 Internet Explorer, 83 process() function, quickstart.js, 23, 26 Opera, 84 Prototype JavaScript framework, 238 ping.html, 81 proxy <strong>PHP</strong> script, 85 ping.js, 81 proxy server script, 85 removePointInfo() function, realTimeChart.js, proxy server script for remote access 201 error_h<strong>and</strong>ler.php, 88 repetitive asynchronous requests, 91 proxyping.html, 86 repetitive tasks implementation proxyping.js, 86 error_h<strong>and</strong>ler.php, 97 proxyping.php, 88 smartproxyping.html, 93 public interface, classes, 110 smartproxyping.js, 94, 98 public members, classes, 110 smartproxyping.php, 97 requestNewMessages() function, <strong>AJAX</strong> chat, Q 162 responseText() method, XMLHttpRequest, 47 queue, 125 responseXML() method, XMLHttpRequest, 47 Quickstart <strong>AJAX</strong> application retrieveNewMessages() function, <strong>AJAX</strong> chat, 163 index.html, 21 RSS, 223 quickstart.js, 21, 23 RSS Reader application quickstart.php, 22 config.php, 228 quickstart application, <strong>AJAX</strong>, 18 error_h<strong>and</strong>ler.php, 227 index.php, 228, 233 R rss_reader.class.php, 227 rss_reader.css, 231 rss_reader.js, 229, 234 r<strong>and</strong>om numbers, retrieving, 93 rss_reader.php, 226, 235 RDBMS, 101 rss_reader.xsl, 227, 235 reading data, remote server, 85 readMessages() function, <strong>AJAX</strong> chat, 162 readyState() method, XMLHttpRequest, 47 S Really Simple Syndication (RSS) about, 223 save() function, 221 document structure, 224 saveXML() function, 71 Google Reader, 224 Scalable Vector Graphics (SVG), 189 RSS reader application, 226 script element, embedding Java code, 30 realtime charting with <strong>AJAX</strong>, 190 script.aculo.us, 237, 238 271 www.it-ebooks.info
- Page 1 and 2:
www.it-ebooks.info
- Page 3 and 4:
AJAX and PHP Building Responsive We
- Page 5 and 6:
About the Authors Cristian Darie is
- Page 7 and 8:
About the Reviewers Emilian Balanes
- Page 9 and 10:
Table of Contents Preface 1 Chapter
- Page 11 and 12:
Table of Contents Chapter 6: AJAX S
- Page 13 and 14:
Preface AJAX is a complex phenomeno
- Page 15 and 16:
Preface What You Need for This Book
- Page 17 and 18:
Preface Errata Although we have tak
- Page 19 and 20:
1 AJAX and the Future of Web Applic
- Page 21 and 22:
Chapter 1 Because end-user satisfac
- Page 23 and 24:
Chapter 1 Three points for you to k
- Page 25 and 26:
Chapter 1 With JavaScript, develope
- Page 27 and 28:
interrupting the user from his or h
- Page 29 and 30:
• Creating simple online chat sol
- Page 31 and 32:
Chapter 1 done typing. (This method
- Page 33 and 34:
Chapter 1 All exercises from this b
- Page 35 and 36:
etrieve the user name $name = $_GET
- Page 37 and 38:
Chapter 1 If you're curious to test
- Page 39 and 40:
Chapter 1 request. In our case, thi
- Page 41 and 42:
2 Client-Side Techniques with Smart
- Page 43 and 44:
AJAX Foundations: JavaScript and
- Page 45 and 46:
Chapter 2 • Because there is no s
- Page 47 and 48:
Time for Action—Using JavaScript
- Page 49 and 50:
Even More DOM In the previous exerc
- Page 51 and 52:
Chapter 2 What Just Happened? Well,
- Page 53 and 54:
Chapter 2 font-size: 10pt; } .Table
- Page 55 and 56:
Chapter 2 Creating the XMLHttpReque
- Page 57 and 58:
Chapter 2 You could, for example, c
- Page 59 and 60:
You will learn the most interesting
- Page 61 and 62:
Chapter 2 The safer version of proc
- Page 63 and 64:
Chapter 2 4. Create a file call
- Page 65 and 66:
Chapter 2 Figure 2.6: The Four HTTP
- Page 67 and 68:
Chapter 2 } } else { // display sta
- Page 69 and 70:
Chapter 2 } { // try to create XMLH
- Page 71 and 72:
Chapter 2 The responseXML method of
- Page 73 and 74:
Chapter 2 Figure 2.10: Opera Displa
- Page 75 and 76:
I admit that the following piece of
- Page 77 and 78:
3 Server-Side Techniques with PHP a
- Page 79 and 80:
Chapter 3 } for (var i=0; i
- Page 81 and 82:
Chapter 3 // create the element $b
- Page 83 and 84:
Chapter 3 // create the root eleme
- Page 85 and 86:
Chapter 3 // read a file from the s
- Page 87 and 88:
Chapter 3 Figure 3.3: PHP Parameter
- Page 89 and 90:
Chapter 3 Without the customized er
- Page 91 and 92:
} } // display the error in case of
- Page 93 and 94:
Chapter 3 Figure 3.7: Connecting to
- Page 95 and 96:
Chapter 3 } } // continue only if H
- Page 97 and 98:
Chapter 3 You can make Firefox list
- Page 99 and 100:
Chapter 3 } "MSXML2.XMLHTTP.4.0", "
- Page 101 and 102:
'TEXT: ' . $errStr . chr(10) . 'LOC
- Page 103 and 104:
etrieve the parameters $num = 1; //
- Page 105 and 106:
Chapter 3 Figure 3.16: Flowchart De
- Page 107 and 108:
} Chapter 3 // only continue if xml
- Page 109 and 110:
} throw(response.length == 0 ? "Ser
- Page 111 and 112:
function process() { // ... if (req
- Page 113 and 114:
Chapter 3 Working with MySQL A back
- Page 115 and 116:
Chapter 3 Figure 3.17: Executing SQ
- Page 117 and 118:
Chapter 3 SELECT user_id, user_name
- Page 119 and 120:
3. In your foundations folder, crea
- Page 121 and 122:
Chapter 3 After these commands exec
- Page 123 and 124:
Chapter 3 • friendly.php is a PHP
- Page 125 and 126:
This example requires a JavaSc
- Page 127 and 128:
} } // try to connect to the server
- Page 129 and 130:
Chapter 3 } // create HTML-formatte
- Page 131 and 132:
Chapter 3 On the server side, all t
- Page 133 and 134:
4 AJAX Form Validation Validating i
- Page 135 and 136:
Chapter 4 Always validate user inpu
- Page 137 and 138:
Chapter 4 Figure 4.4: Successful Su
- Page 139 and 140:
Chapter 4 .left { margin-left: 150p
- Page 141 and 142:
Chapter 4 value="" />
- Page 143 and 144:
Registration Successfull! <<
- Page 145 and 146:
Chapter 4 } } { // display error me
- Page 147 and 148:
Chapter 4 require_once ('config.php
- Page 149 and 150:
Chapter 4 } { } $_POST['txtBthDay']
- Page 151 and 152:
Chapter 4 } } ?> return ($value ==
- Page 153 and 154:
Chapter 4 The field ID and value re
- Page 155 and 156:
Chapter 4 If we are dealing with cl
- Page 157 and 158:
5 AJAX Chat We are living in a worl
- Page 159 and 160:
Chapter 5 Implementing AJAX Chat We
- Page 161 and 162:
Chapter 5 // default the last id to
- Page 163 and 164:
} Chapter 5 ' DATE_FORMAT(posted_on
- Page 165 and 166:
Chapter 5 AJAX Chat Your b
- Page 167 and 168:
* function called when the Send but
- Page 169 and 170:
} } // retrieve the arrays from the
- Page 171 and 172:
Chapter 5 } } } // call server asyn
- Page 173 and 174:
Chapter 5 If you analyze the code f
- Page 175 and 176:
The business logic behind chat.php
- Page 177 and 178:
6 AJAX Suggest and Autocomplete Sug
- Page 179 and 180:
Chapter 6 The clever part of the Ja
- Page 181 and 182:
Chapter 6 6. Create another file na
- Page 183 and 184:
Chapter 6 { } a { } font-weight: bo
- Page 185 and 186:
Chapter 6 } { // try to create XMLH
- Page 187 and 188:
Chapter 6 } } } } { } displayError(
- Page 189 and 190:
Chapter 6 div += "" + "" + crtFunct
- Page 191 and 192:
} } // select the new suggestion an
- Page 193 and 194:
Chapter 6 } } else // FF if (oText.
- Page 195 and 196:
Chapter 6 Figure 6.4: PHP Documenta
- Page 197 and 198:
Chapter 6 We have talked about cach
- Page 199 and 200:
Chapter 6 visible, we need to scrol
- Page 201 and 202:
7 AJAX Real-Time Charting with SVG
- Page 203 and 204:
Chapter 7 Figure 7.1: SVG Chart The
- Page 205 and 206:
Chapter 7 Figure 7.2: SVG Charting
- Page 207 and 208:
Chapter 7 } { xmlHttp.onreadystatec
- Page 209 and 210:
} } // sets the X and Y attributes
- Page 211 and 212:
Chapter 7 } // Supported by Mozilla
- Page 213 and 214:
Chapter 7 • All HTTP requests go
- Page 215 and 216:
8 AJAX Grid Data grids have always
- Page 217 and 218:
Chapter 8 Figure 8.2: AJAX Grid in
- Page 219 and 220:
$name = $_GET['name']; // update th
- Page 221 and 222:
} Chapter 8 if (!isset($_SESSION['r
- Page 223 and 224:
Chapter 8 # editId(, true) Edit
- Page 225 and 226:
Chapter 8 } // this should work for
- Page 227 and 228:
} Chapter 8 if(editableId) editId(e
- Page 229 and 230:
} color: darkblue; text-align: righ
- Page 231 and 232: Chapter 8 On the client, this data
- Page 233 and 234: Chapter 8 save() and undo() are hel
- Page 235 and 236: 9 AJAX RSS Reader In the last few y
- Page 237 and 238: Chapter 9 Figure 9.1: Managing RSS
- Page 239 and 240: header('Pragma: no-cache'); header(
- Page 241 and 242: Chapter 9 Loading feed... Abou
- Page 243 and 244: Chapter 9 } // continue if the proc
- Page 245 and 246: Chapter 9 } width: 410px; backgroun
- Page 247 and 248: And finally, we send the HTTP reque
- Page 249 and 250: 10 AJAX Drag and Drop When drag-and
- Page 251 and 252: Chapter 10 The Prototype features a
- Page 253 and 254: Chapter 10 When dropping a task on
- Page 255 and 256: Chapter 10 DROP HERE TO DELETE
- Page 257 and 258: header('Expires: Fri, 25 Dec 1980 0
- Page 259 and 260: Chapter 10 } } } else if (action ==
- Page 261 and 262: Chapter 10 11. Load http://localhos
- Page 263 and 264: details are saved using a cache sys
- Page 265 and 266: Chapter 10 Summary This is it! You'
- Page 267 and 268: A Preparing Your Working Environmen
- Page 269 and 270: Appendix A During installation you'
- Page 271 and 272: Before going through any case studi
- Page 273 and 274: Appendix A Preparing Your *nix Play
- Page 275 and 276: 8. Finally, point your web browser
- Page 277 and 278: 2. Write ajax in the Create a new d
- Page 279 and 280: Index A abort() method, XMLHttpRequ
- Page 281: exception handling, JavaScript, 43
- Page 285 and 286: updateChart() function, realTimeCha