Jump to content

Form with Post, able to be converted?


derrick1123

Recommended Posts

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
?>

Link to comment
Share on other sites

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>
"; ?>

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.