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
https://forums.phpfreaks.com/topic/134868-form-with-post-able-to-be-converted/
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>
"; ?>

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.