Results 1 to 2 of 2

Thread: how to update mydiv without refresh page?

  1. #1
    Join Date
    Jan 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy how to update mydiv without refresh page?

    hi
    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:
    Code:
    <style> 
    
    .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;
    }
    
    </style> 
    
    
    <div id="MyDiv" class="middle_area_bg">
    
    <center>
    <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"> 
    
    <td>
    <font  onClick="document.form1.video.value='http://youtube.com/watch?v=oIFmhye6fqw'" color="#ffffff" size=2>
    Example:
    <br>
    http://youtube.com/watch?v=oIFmhye6fqw
    </font>
    </td>       
    <img id="pic" src="http://superiran.dk/tubeget/images/l1.jpg">
    </form> 
    </center>
    
    </div>
    and (y.php) is :

    Code:
    <?
    if(eregi('youtube.com',$_POST['video'])){
    $video="$_POST[video]";
    $video2 = explode("watch?v=", $video);
    $video2 = explode("&", $video2[1]);
    $video2 = $video2[0];
     $source = file_get_contents($video);
    
    preg_match("/var fullscreenUrl = '(.*?)';/is", $source, $link);
    $link=str_replace('/','',$link[1]);
    $link=str_replace("watch_fullscreen?",'',$link);
    $title = explode("<title>", $source);
    $title = explode("</title>", $title[1]);
    $title=str_replace("YouTube - ","",$title[0]);
    $pic="http://img.youtube.com/vi/$video2/default.jpg";
    
    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??!!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •