derrick1123 Posted November 30, 2008 Share Posted November 30, 2008 I want the following to use ajax to load, but couldn't think of a good way to do it. I know my coding styles are not clean, sorry. <? echo " <a href='?l=1&type=videos&video=".$video."&autostart=true'>Videos List</a> | <a href='?l=1&type=movies&video=".$video."&autostart=true'>Movies List</a> | <a href='?l=1&type=uvideos&video=".$video."&autostart=true'>User Uploaded List</a> | <a href='?l=1&type=htf&video=".$video."&autostart=true'>Happy Tree Friends Videos</a><br> "; //// VIDEOS if($type=="videos"){ echo "<form method=get><select name=video>"; $dir = "videos/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($rfile = readdir($dh)) !== false) { if($rfile=="." || $rfile==".." || $rfile=="" || $rfile==" ") { } else { echo "<option value=\"".$rfile."\">".$rfile."</option>"; } } closedir($dh); } } echo "</select>"; echo "<input type=hidden name=l value=1><input type=hidden name=type value=videos>"; echo "<input type=submit value=load></form>"; } //...etc ?> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 30, 2008 Share Posted November 30, 2008 Can you elaborate? Do you mean when the user clicks the menu links across the top, the content changes without the page reloading? Quote Link to comment Share on other sites More sharing options...
derrick1123 Posted November 30, 2008 Author Share Posted November 30, 2008 Yes, that's exactly how I was thinking it would work. Ajax just blows my mind, so nothing to me seems logical. Most of Ajax seems like magic. Quote Link to comment Share on other sites More sharing options...
derrick1123 Posted November 30, 2008 Author Share Posted November 30, 2008 I was going to edit my other post... I just want to figure out how to send some variables and display the information, like whether or not to show the video player. Quote Link to comment Share on other sites More sharing options...
corbin Posted November 30, 2008 Share Posted November 30, 2008 Have you even tried? What you're trying to do isn't very hard. Read an AJAX tutorial or two and it won't seem like magic anymore. Quote Link to comment Share on other sites More sharing options...
derrick1123 Posted November 30, 2008 Author Share Posted November 30, 2008 This is what I tried: Alpine's Ajaxrequest.js script. http://www.phpfreaks.com/forums/index.php/topic,115581.0.html index.php <script type="text/javascript" language="javascript" src="src/ajaxrequest.js"></script> <!--Yes, I know its in a folder called src--> <div id="player"> <? if($l=="1"){ ?> <div id="container"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div> <script type="text/javascript"> var s1 = new SWFObject("player.swf","ply","428","300","9","#000000"); s1.addParam("allowfullscreen","true"); s1.addParam("allowscriptaccess","always"); s1.addParam("flashvars","file=<? echo $type."/".$video; ?>&autostart=true"); s1.write("container"); </script> <? } if($embed_code==true){?> <? }?> </div> <? echo " <a href="javascript: MyAjaxRequest('player','index.php?l=1&type=".$type."&video=".$video."&autostart=true')">Play Video</a> "; ?> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 30, 2008 Share Posted November 30, 2008 i would shy away from loading the content via AJAX because it isn't SEO friendly. instead, do a DIV for each 'section' and hide all the other DIVs. Then, when they click on each menu item, hide the DIV that is showing, and show the new one. that way all the content is there for search engines to parse. if you still want to load via AJAX, jQuery has a REALLY easy way: $('#contentDiv').load('page.php',{'data':'value'}); where contentDiv is the name of the DIV to load the page into, page.php is the page to load, and the data/value stuff is data to pass via GET. that code would go in the onclick of the menu items read more on that here: http://docs.jquery.com/Ajax Quote Link to comment Share on other sites More sharing options...
derrick1123 Posted November 30, 2008 Author Share Posted November 30, 2008 lol, for now I don't want search engines to find my site. Thanks for this information though, much appreciated. 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.