nutt318 Posted February 10, 2009 Share Posted February 10, 2009 I have the following code when clicking the button in modifies a text file. Is there a way that I can click the button without the page refreshing? Basically there is a video feed on this same page and i have to restart it when clicking the button because it refreshes the page. <?php if($_POST['Submit']){ $open = fopen("test.txt","a+"); $text = "Left\n"; fwrite($open, $text); fclose($open); } echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">"; echo "<input name=\"Submit\" type=\"submit\" value=\"Left\" />\n </form>"; ?> Can I use a frame or a different type of php code? Thanks. Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/ Share on other sites More sharing options...
Maq Posted February 10, 2009 Share Posted February 10, 2009 Not with PHP. You would have to use AJAX to make a server call without a page refresh. Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/#findComment-759048 Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 You can use an IFRAME or look into AJAX. Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/#findComment-759052 Share on other sites More sharing options...
Goafer Posted February 10, 2009 Share Posted February 10, 2009 AJAX is definitely worth looking into, seems a bit hard at first but once you've worked out the dynamics of it, it is very useful. Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/#findComment-759057 Share on other sites More sharing options...
nutt318 Posted February 10, 2009 Author Share Posted February 10, 2009 Well it looks like I need to look at AJAX then. Is there a certain section or functions that I should be looking at in order to duplicate the PHP code? Thanks guys. Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/#findComment-759063 Share on other sites More sharing options...
mat-tastic Posted February 10, 2009 Share Posted February 10, 2009 Go here: http://www.phpfreaks.com/forums/index.php/topic,115581.0.html That will get you started on AJAX. Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/#findComment-759065 Share on other sites More sharing options...
nutt318 Posted February 10, 2009 Author Share Posted February 10, 2009 Thanks for the link mat-tastic. Link to comment https://forums.phpfreaks.com/topic/144656-solved-click-button-without-page-refresh/#findComment-759100 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.