west4me Posted September 29, 2007 Share Posted September 29, 2007 I do not know what I am doing at all.... thought that should give you an idea where I am coming from. I am a teacher and to be as unbiased as possible I use a name randomizer script to call on students. I used to do this with a java script but it had to reload the page every time. I figured ajax would do the trick. I found a randomizer script and adopted it to my needs. The script is working wonderfully in Firefox but really craps out in IE. Since I know nothing about ajax I don't even know where to start. Any help would be appreciated. Here is the site that I use the script on: http://cunninghamclassroom.com/name/name.html Here is the code that runs on that page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Ajax with jQuery Example</title> <script type="text/JavaScript" src="/name/jquery.js"></script> <script type="text/JavaScript"> $(document).ready(function(){ $("#generate").click(function(){ $("#quote p").load("script.php"); }); }); </script> <style type="text/css"> body { background: #000; } form { margin: 0; padding: 0; } fieldset { border: 0; margin: 0; padding: 0; } #chooser ul { margin: 0; padding: 0; } #chooser li { list-style: none; width: 172px; height: 150px; } #chooser button { background: url(button-p.jpg) bottom left no-repeat; color: #fff; cursor: pointer; border: 0; display: block; font-family: "Lucida Sans Unicode", "Lucida Grande", "Trebuchet MS", Helvetica, Arial, sans-serif; margin: 0; padding: 0; width: 175px; height: 150px; } button h3 { background: top left no-repeat; font-size: 1.6em; font-weight: normal; letter-spacing: 2px; line-height: 50px; width: 175px; margin: 0; padding: 0; position: relative; left: -3px; } * html button h3 { position: static; } #chooser button p { color: #555; font-size: 1.6em; margin: 0; padding: 10px; text-align: center; width: 145px; } * html #chooser button p { font-size: .9em; } .basic button h3 { background-image: url(li-pro-h3.jpg); } #move { margin-left: 5px; margin-top: -21px; } </style> </head> <body> <div id="move"> <form id="chooser" action="#" method="get"> <fieldset> <ul> <li class="basic"><button type="submit" id="generate" value="Generate!"> <h3>Student</h3> <div id="quote"><p>Click It!</p></div> </button></li> </ul> </fieldset> </form> </div> </body> </html> And here is the script: <?php header("Cache-Control: no-cache"); // Ideally, you'd put these in a text file or a database. // Put an entry on each line of 'a.txt' and use $prefixes = file("a.txt"); // You can do the same with a separate file for $suffixes. $prefixes = array('Dylan','Brandon','Clerence','Stephen','Trey','Jadon','Blake','Torsten','Kaleb','Angelica','Brittany','Rosalie','Hope','Mackenzie','Makayla','Makayli','Alexis','Savanna'); // This selects a random element of each array on the fly echo $prefixes[rand(0,count($prefixes)-1)] . "" ?> Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted October 5, 2007 Share Posted October 5, 2007 I think ie has trouble with the formed html Try removing the form since ajax doesnt require it and build the html in a better way. And is ajax or that fance button really needed it can be done without any php or is that php file required? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.