Wednesday, 25 January 2012

AJAX

So I was doing some work on the photo gallery today...I had no clue. I have a habit of thinking of things before I sleep, and these past few nights have been full of dreams about MySQL arrays and the possibilities. So today, I jotted down a couple of options I could take with the comments system.

So I went with option 2-which I titled "Hard, but not as tedious". But first I needed to make a huge drop down list for the comments form. now THAT seemed tedious. I looked at ww3schools.com and they showed me how to do a drop down menu. basically you have your list in a
<option> thing 1 </option>
<option> thing 2 </option>
After typing out 3 of these, I decided "No way. There has to be a quicker way." I asked myself, what could generate all of these quickly. The answer came to me quickly-excel.
So i copied and pasted what was generated, deleted the empty spaces, and voila. Job done. It probably took me a third of the time that was needed to do it all by hand.
By the way, these are all IDs that i gave each and every photo. For example, the first photo in the 2011 lot is calleed 2011_1
So i added these IDs to the menu that pops up under each photo so that students can quickly know what the photo they want to comment on is.
And, here it is! My drop down menu.
So now, another problem has arisen. What do I do after the user has filled in the form and clicked submit...well currently, my code says "after the button is clicked, show an alert telling the person that they have commented, then return true-redirect them to the page with the close button"
Well, now i need "after the button is clicked, FIRST, insert everything into the mysql table (use PHP), THEN show an alert telling the person that they have commented, then return true-redirect them to the page with the close button"


This means that I need to somehow put PHP into Javascript. I seem to recall searching this up-everything pointed me to AJAX. But i searched it up again anyway
http://www.hotscripts.com/forums/javascript/39278-php-inside-javascript.html
This website confirmed that i need AJAX. Fine, I'll do some notes and some research on it tommorow

No comments:

Post a Comment