hiya guys,
I have a question, i want to display the image which is above the page, while my script loads in the background.
This is a simple script which check for new messages in my mailbox, so it is more like GMAIL's loading bar which is shown just before we land into our mailboxes.
Guys, how do i do it ? Because i have tried ob_start and ob_end_flush, but with no luck i am unable to see the image before script terminates. The whole data is shown into browser in one go. How do i slice it ..
The piece of code is like this ::
[PHP]
<?php
require_once("lib/POP3.php");
include('lib/mimeDecode.php');
require_once("../config/config.inc.php");
echo '<img src="loader.gif" />';
function gmail($em){
$start=strrpos($em,"<");
$end=strrpos($em,">");
$len=$start+4;
$email=substr($em,$len,$end-$len);
return $email;
}
/****************** Function to parse message and splits the needful into parts *******************/
function parse_output(&$obj, &$parts){
if(!empty($obj->parts)){
for($i=0; $i<count($obj->parts); $i++)
parse_output($obj->parts[$i], $parts);
}else{
$ctype = $obj->ctype_primary.'/'.$obj->ctype_secondary;
switch($ctype){
case 'text/plain':
if(!empty($obj->disposition) AND $obj->disposition == 'attachment'){
$parts['attachments'][] = $obj->body;
}else{
$parts['text'][] = $obj->body;
}
break;
case 'text/html':
if(!empty($obj->disposition) AND $obj->disposition == 'attachment'){
$parts['attachments'][] = $obj->body;
}else{
$parts['html'][] = $obj->body;
}
break;
default:
$parts['attachments'][] = $obj->body;
$parts['attachments']['name']=$obj->ctype_parameters['name'];
}
}
}
/*************** Variable Initialization ************/
$user='realin@domain.com';
$pass='realin';
$host='mail.domain.com';
$port="110";
$commid=(int)"6";
/*@ var total number of messages
in the inbox */
$nTotal="";
/* @var Messages which are
being retrieved */
$retr="";
$my=array();
$data=array();
$obj=&new Net_POP3();
$obj->connect("$host","$port");
$ret=$obj->login($user , $pass,'USER' );
if(is_object($ret))
echo "Invalid Username/Password";
/********** Gets the office status of the mailbox, viz number of messages,size,UID *************/
$listing=$obj->getListing();
foreach($listing as $l){
$id=$l["msg_id"];
$head[$id]=$obj->getParsedHeaders($id);
$body[$id]=$obj->getMsg($id);
}
?>
[/PHP]
20 13341 hsriat 1,654
Recognized Expert Top Contributor
This is a JavaScript thing, something like this...
[php]<?php
//start sessions or whatever...
//send headers.....
echo "<script type=\"text/javascript\">document.write('<div id="loading">Loading...</div>')";
//do your php processing....
//and send the body tag like this..
echo "<body onload=\"this.style.display=''; document.removeChild('loading');\" style=\"display:none;\">[/php]
Not tested, but this may work.
This is a JavaScript thing, something like this...
[php]<?php
//start sessions or whatever...
//send headers.....
echo "<script type=\"text/javascript\">document.write('<div id="loading">Loading...</div>')";
//do your php processing....
//and send the body tag like this..
echo "<body onload=\"this.style.display=''; document.removeChild('loading');\" style=\"display:none;\">[/php]
Not tested, but this may work.
thanks buddy,
gonna try now ..
cheers !!
hsriat 1,654
Recognized Expert Top Contributor
thanks buddy,
gonna try now ..
cheers !!
Do some changes if it didn't work, but I think this thing will work.
Regards
Not tested, but this may work.
Din work for me mate :((
hsriat 1,654
Recognized Expert Top Contributor
Din work for me mate :((
What did you try?
This is a JavaScript thing, something like this...
[php]<?php
//start sessions or whatever...
//send headers.....
echo "<script type=\"text/javascript\">document.write('<div id="loading">Loading...</div>')";
//do your php processing....
//and send the body tag like this..
echo "<body onload=\"this.style.display=''; document.removeChild('loading');\" style=\"display:none;\">[/php]
Not tested, but this may work.
Hi,
Can you tell me how would you execute javascript if the PHP hasn't finished executing. As it hasn't finished executing PHP it wont appear even on client browser and as per my knowledge javascript will work on client side only and that too after the javascript code is loaded..
Let me know if i'm wrong somewhere...
Regards,
RP
Hi,
According to me you need to use Ajax for that.
Load whole page with Ajax. Display whatever you want to display on page on loading and in backgraound call your PHP script and then when reply comes back replace/hide your image and load the result...
And as per my knowledge even Google has used Ajax....
Regards,
RP
Hi,
According to me you need to use Ajax for that.
Load whole page with Ajax. Display whatever you want to display on page on loading and in backgraound call your PHP script and then when reply comes back replace/hide your image and load the result...
And as per my knowledge even Google has used Ajax....
Regards,
RP
kewll..
that is the only option left now.. and you are right in saying taht first php will execute and then the compiled thing is returned to client i.e. browser thru RESPONSE headers and then JS comes into play
true :)
Hi,
I came up with this solution.
AJAX+PHP Solution....
HTML page which calls the PHP script PHPAjax.html
[HTML]
<html>
<head>
<script type="text/javascript">
document.write('<div id="loading">Loading...</div>');
//Ajax Function
function getHTTPObject()
{
var xmlhttp;
if (window.ActiveXObject)
{
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (E)
{
xmlhttp = false;
}
}
}
else
{
xmlhttp = false;
}
if (window.XMLHttpRequest)
{
try
{
xmlhttp = new XMLHttpRequest();
}
catch (e)
{
xmlhttp = false;
}
}
return xmlhttp;
}
//HTTP Objects..
var http = getHTTPObject();
//Function which we are calling...
function AjaxFunction()
{
url='PHPScript.php';
http.open("GET",url, true);
http.onreadystatechange = function()
{
if (http.readyState == 4)
{
//Change the text when result comes.....
document.getElementById("loading").innerHTML=http. responseText;
}
}
http.send(null);
}
</script>
</head>
<body onload="AjaxFunction()">
</body>
</html>
[/HTML]
Background PHP Script PHPScript.php
[PHP]
<?php
sleep(10);
echo "I'm from PHP Script";
?>
[/PHP]
Save both the file in same directory. From browser execute the HTML file... It will show you 'loading...' at first wait for 10 seconds.. and you will see the message changing to "I'm from PHP Script".. if everything works fine....
Let me know if you find any problem or if it helps...
Regards,
RP
And can anyone tell me.. what is wrong with code tags here on site..
I cant get any tag working... everything shows up as
[HTML]
something
[/HTML]
eventhough i'm using Mysql, PHP or HTML tags...
Anyways... Going home.. see you tomorrow... bbye...
Regards,
RP
Atli 5,058
Recognized Expert Expert
And can anyone tell me.. what is wrong with code tags here on site..
The highlighting software was causing problems and was removed.
I do believe they are searching for alternatives tho.
hsriat 1,654
Recognized Expert Top Contributor
And gmail came back with a loading bar...
I was expecting that though....
Now how to make that?
dlite922 1,584
Recognized Expert Top Contributor
And gmail came back with a loading bar...
I was expecting that though....
Now how to make that?
To me this is not possible because PHP comes back after the processing is done.
I guess you'd split the PHP calling into multiple and call each one with Ajax and just update the bar with each call. A very stupid way of doing it, but that would have that affect; it will most definetly not be a smooth bar though (like vista style)
The most common thing is having a looping ajax loader .gif image.
hsriat 1,654
Recognized Expert Top Contributor
Well, I have another idea for realin, if he's interested. -
<html>
-
<head><title>realin</title>
-
<style type="text/css">
-
body {background-image:url('loading_image.gif');}
-
</style>
-
</head>
-
<body onload="document.getElementById('body').style.display=''; this.style.backgroundImage='none';">
-
<div id="body" style="display:none;">
-
<!--
-
body goes here
-
-->
-
</div>
-
</body>
-
</html>
guys,
really thanks a lot..
I gonna go for ajax like loading tomm morning..
Hope this works :)
*makes a note to myself: someday I am gonna learn Ajax, until then I keep sticking to my Javascript and an iframe doing my background queries and script calls*
:))
hsriat 1,654
Recognized Expert Top Contributor
*makes a note to myself: someday I am gonna learn Ajax, until then I keep sticking to my Javascript and an iframe doing my background queries and script calls*
:))
Believe me, its not a day's job. Rather its just minutes' job, if you know JavaScript.
Believe me, its not a day's job. Rather its just minutes' job, if you know JavaScript.
Yeah, I suspect that is true, probably why I haven't bothered yet :))
dlite922 1,584
Recognized Expert Top Contributor
Yeah, I suspect that is true, probably why I haven't bothered yet :))
"To fear the unknown is equal to fearing knowledge." --Dan M.
TheServant 1,168
Recognized Expert Top Contributor
"To fear the unknown is equal to fearing knowledge." --Dan M.
The fear of the LORD is the beginning of knowledge; fools despise wisdom and instruction. -- King Solomon & God
Been reading Proverbs recently!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Al Davis |
last post by:
Note: I tried cross-posting this message to several newsgoups,
including comp.lang.perl.misc, c.l.p.moderated,
comp.infosystems.www.authoring.cgi, comp.lang.javascript and
comp.lang.php. Nothing...
|
by: Dj Frenzy |
last post by:
Hi, I know how to use javascript to change a background image to
another background image, and how to change a background colour to
another background colour. Is there a way to change an image to a...
|
by: Amir |
last post by:
Hi,
I'd like to know if it's possible to pass an image name (the IMG SRC
attribute) from HREF element to a function that is activated by onClick
event and creates a Web page.
I have this HREF...
|
by: Littlefire |
last post by:
Hi all
I wrote a proxy script that fetches images out of a database and sends the
data to the browser, using the Content-type header. For instance, if I'm
loading a jpg image from the database,...
|
by: M |
last post by:
Hi all,
This is the script I use to find coordinates on a map and transfer
them to textfields in the openerwindow.
++++++++++++++++++++++++
<HTML>
<HEAD>
<TITLEMouse Coords </TITLE>
<script...
|
by: rsteph |
last post by:
I've got some product information pages, with images and text, all setup within a table. I'm trying to add a small image in the upper right hand corner of the content div (where all the important...
|
by: yogarajan |
last post by:
Hi All
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<style type="text/css">
#map {
|
by: stevedude |
last post by:
CSS newbie again. I have a problem trying to get coffee mug images
within anchor tags to center with my link text for a vertical list
menu. If I use the horizontal/vertical properties of...
|
by: oranoos3000 |
last post by:
hi
would you please help me
i have a online shopping center that i show pictures of the my product in home page.
in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |