View Full Version : how to update mydiv without refresh page?

04-01-2009, 03:34 PM
in this page http://superiran.dk/tubeget/1.php

show link flv youtube but i wana when click submit my form display ( link flv&info) into mydiv and no refresh page only refresh div??
my form is:


.middle_area_bg {
background-image: url(http://superiran.dk/tubeget/images/middle_area_bg.png);
background-repeat: no-repeat;
background-position: center top;
height: 297px;
width: 415px;


<div id="MyDiv" class="middle_area_bg">

<form method='post' action='y.php' name="form1" >
<input name='video' id="video" type='text' AutoComplete="off" onfocus="this.value=''" onclick="this.value='' " size="50"/>
<input type="submit" name="button1" value="Get it">

<font onClick="document.form1.video.value='http://youtube.com/watch?v=oIFmhye6fqw'" color="#ffffff" size=2>
<img id="pic" src="http://superiran.dk/tubeget/images/l1.jpg">


and (y.php) is :

$video2 = explode("watch?v=", $video);
$video2 = explode("&", $video2[1]);
$video2 = $video2[0];
$source = file_get_contents($video);

preg_match("/var fullscreenUrl = '(.*?)';/is", $source, $link);
$title = explode("<title>", $source);
$title = explode("</title>", $title[1]);
$title=str_replace("YouTube - ","",$title[0]);

echo"<center><img src=\"http://superiran.dk/tubeget/images/info.png\" ><br><font size=\"2\"><b>Name:&nbsp;</b><b>$title</b></font><br><br><img src=\"$pic\"><br><br><img src=\"http://superiran.dk/tubeget/images/download.png\"><br><a href=\"http://www.youtube.com/get_video?$link\"><strong>Click Here to Download Your Video</strong></a></center>";


how to update mydiv with ajax and no refresh page
please help me??!!

04-01-2009, 04:53 PM
Because there will be a server request either way, and more importantly because video code added to a page more than once or removed from a page even once can confuse some browsers (they may go on playing the sound for instance, even though the player code has been overwritten or removed), I'd say stick with what you've got.

However, if you did want to pursue it, you would use the onsubmit event of the form along with an AJAX routine adequate to the purpose.