Recording Puzzle Information

Now that we have created a table to record our information, we need to work on saving data from the puzzle to it. Because we want this to feel like an application, we can take care of the posting of scores to the server with AJAX. Since we already have jQuery included for this project, this is a really simple refactor. As with any AJAX code, there are two pieces: the server-side code that processes the request and the client side that initiates it. I will start with the JavaScript to build the AJAX request and send it to the server and then implement the server side response.

Passing data in AJAX can be quite simple. For our purposes, I am creating a new object in the javascripts/puzzle.js file to hold the data the ...

Get Beginning Facebook Game Apps Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.