FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


is there any way to trigger a .php file without refreshing?





afracsass
I couldn't find a proper thread for my question
if you happen toknow, just direct me to the post.

The problem i'm seeing is this.
Whenever i submit a form using post method, the current page is replaced by .php page and never returns to the original page.
I know i can put some kind of header() function to return to the original page but i don't like my page to be reloaded and flashed.

Is it possible to call a .php file and run it like a background process so that i won't be bothered by flashing page?

thanks,
ranzon
have you tried to put header(firstsite.php) in the bottom of the .php site you don't want?
Kaneda
Quote:
Is it possible to call a .php file and run it like a background process so that i won't be bothered by flashing page?


That's the exact point of the various "Ajax" approaches. You use Javascript, and one of a few methods (usually the XMLHttpRequest object or hidden IFRAMEs) to call the .php, getting back the page in a Javascript property, which you can then simply discard or use to update your page without reloading. The famous examples being GMail and Google Suggest. In simple terms, Javascript talks to the server without anything happening in the browser window.

It's relatively simple to implement if you know Javascript, although there are some pitfalls in terms of browser compatibility etc. It should also always be considered whether using such an approach enhances or degrades the user experience. And in most cases, it would be a good idea to still support the "old way" of doing it, for users who have an old browser, or have Javascript disabled.
afracsass
Thanks for posting you guys. looks like i have to look at what 'Ajax' is. At first i just started to write a php code for fun. and now it pushes me to run too many things, sql, xml, now ajax. i don't know where to stop for this quest. I feel like i know too much for a web surfer Very Happy
Ducksteina
If you understood you right, you want to run a page the whole time. For that, you can use a header to refresh the page.
For example, you can use this code:
Code:
<?PHP
header("refresh:60;url=http://www.yoururl.com/yourscript.php");
?>

After 60 seconds, the script would forward the browser to http://www.yoururl.com/yourscript.php. Don't set the refresh-time too low or it'll generate a lot of traffic.
I hope I could help.
roeenoy
you can always use JavaScript..
just do a timer
if you need any help tell me
afracsass
looks like header function with refresh does not work well with IE. Instead i'll rather write a mimic php code
Code:

<?php
$s_url = 'http://www.frihost.com/main.php?arg1=something&arg2=else';
if (headers_sent()) exit("Headers already sent. Can not redirect to $url");
echo '<meta http-equiv="refresh" content="10; url='.$s_url.'">';
?>


javascript is a clientside script and thus hard to use for modifying files in the server.

thanks...
Stubru Freak
afracsass wrote:
if (headers_sent()) exit("Headers already sent. Can not redirect to $url");


Isn't needed using this method
Related topics
Cron jobs - running a php file
[PHP doubt]Knowing the directory location of PHP file
Uploading a .php file! NEED HELP thanks
what is dump?
400 Frih for Phpbb skin (formaly 800 Reddish Blue Website)
User Viewing A PHP File
send variable from php tp php file
Running PHP Script without PHP Server?
Limiting php file functions with .htaccess
Remote php file access and reading
PHP running PHP
including javascript in php file
Hide PHP file extension
[TuT]JOOMLA Installation Guide(Easiest Way)
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.