innerHTML
= responseText;}
ResultProcessed();
}
4. What remains now is to link up the next and previous recipes via JavaScript.
Let's add this at the top of our recipes.inc.php. Below is the code.
Prev recipe
- Next recipe
- Add a Comment
5. That's all! Clicking on Next or Prev on our recipes page will load up the
appropriate recipe. When all recipes are finished, we will get an apology
message saying there are no more recipes! The following screenshot shows
what the navigation looks like, on the iPhone.
Yes! Simply setting a variable to hold the current index and adjusting it on fetching
the next or previous recipe does the trick for us. The PHP back end expects just the
index, and it fetches one recipe from there. When the code is done, it feels so fluid
navigating among recipes! That's the power of AJAX!
Adding Comments
We want to allow users to submit comments on the recipes displayed. This will
build a community around our recipes service.
Pages:
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261