/    Sign up×
Community /Pin to ProfileBookmark

multiple simultaneous http requests from one browser to php

Im trying to implement a design paradim that requires one browser be making multiple simulatnius calls to php
bascily my javascript calls a frame, that never finishes loading.

all following requests get queued and never fired.

Im hopping this is some sort of setting i can change. My system admin skills are way bellow par.

Thanks in advance.

Nick

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@nicholasjstockauthorNov 08.2009 — Well a day has gone by... And i couldnt figure out why on earth php was getting all tied up.

so, now, instead of having serverside php while loop javascript creates a frame, the frame is set to reload itself onload unless new data is available on the server.

frame.php:

<?php

$x = 1;

$filename = '/var/www/html/lsdf_server/session_data/'.session_id().".serverTrigger";

echo $filename.'<br>';

if (!file_exists($filename)){

$tmp= fopen($filename,'w');

fclose($tmp);

}

//while ($x==1){

//$handle2= fopen($filename,'w+');

//fclose($handle2);

$handle= fopen($filename,'r');

if (filesize($filename)>0){

$contents = fread($handle, filesize($filename));

if ($contents =='3'){

echo "teeeeeeesst";

$x = 0;

echo '<script> x = 0;</script>' ;

}

}

fclose($handle);



//}

?>

<script>

window.onload = function() {

alert('test');

if ((parent.document.getElementById('request_canceled').value !='true')&&(x=="1")){

document.location = document.location;

}else{

alert('data pushed');

}

</scipt>


Nick
Copy linkTweet thisAlerts:
@toicontienNov 08.2009 — Why not use AJAX (Asynchronous Javascript And Xml)? You won't need a frame.
Copy linkTweet thisAlerts:
@nicholasjstockauthorNov 08.2009 — Yeah, thanks Im an idiot....and mostly I had been coding for too long last night. here is the IFrame less version. I have no ideal why I didnt do this this ay first...

Thanks 4 the headsup....

Clientside:

function ping(){

$.post("index.php/proxy/frameRPC/",


{rating: '5'}, function(xml) {
// format and output result
if (xml==3){
getData();
}
ping();
});


}

and frameRPC:

function frameRPC(){



$x = 1;

$filename = '/var/www/html/lsdf_server/session_data/'.session_id().".serverTrigger";

if (!file_exists($filename)){

$tmp= fopen($filename,'w');

fclose($tmp);

}

//while ($x==1){

//$handle2= fopen($filename,'w+');

//fclose($handle2);

$handle= fopen($filename,'r');

if (filesize($filename)>0){

$contents = fread($handle, filesize($filename));

if ($contents =='3'){

echo 3;

//echo "teeeeeeesst";

$x = 0;

//echo '<script> x = 0;</script>' ;

}

}

fclose($handle);



//}



}
×

Success!

Help @nicholasjstock spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...