Reputation: 653
For learning, I'm making a tic tac toe game that's intended to be played between two users online. It uses PHP and MySQL, and lots of jquery and ajax on the frontend.
During a game, players will see the tic tac toe board, and an indication of who's turn it is. It will use ajax/jquery to update all of this info without page refreshes - at least that is my intent.
I need to have it query for each field of the board. I can fairly simply do this with nine different routines, but that seems terribly inefficient. Can a jquery ajax procedure be written which will hit the php/sql backend and get updates for all nine cells?
Upvotes: 0
Views: 109
Reputation: 3117
Look into json - your php can return a single string representing an object that contains as much information as you want (well, within reason). Using jQuery.getJSON(), the string will automagically be read into a javascript object, and the javascript on your page can read the info from the object at will.
Upvotes: 3