joeyjgarcia Posted June 7, 2006 Share Posted June 7, 2006 I wanted to use AJAX on the client side and PHP for the server side technology and I wanted to be able to have a user select many check boxes and send the values to the PHP code and the PHP code would then contact a web service to obtain some information and return the data to the AJAX client.Question: Since AJAX is asynchronous how will PHP handle multiple requests fired at it? I know I could batch them up and send one batch of values, but I was wonder how PHP will handle multiple request to that same server-side php page. Would I need to use session on the server side to handle these? Quote Link to comment https://forums.phpfreaks.com/topic/11416-php-wajax/ Share on other sites More sharing options...
.josh Posted June 7, 2006 Share Posted June 7, 2006 the script would be run once per request. just like pressing the submit button several times. the only difference between the ajax method and regular posting method is that ajax posts just the little piece of info, receives the results and updates one piece of the page, instead of the whole thing. All the other principles apply here. It's just on a smaller scale.in other words:if your php script were to look like this:$x = $_REQUEST['x'];$y = $_REQUEST['y'];$z = $_REQUEST['z'];$total = $x + $y + $z;if you sent a request to the server containing all 3 of those variables, $total would be the sum of all 3 of them. However, if you did 3 seperate requests, one for each variable, $total would not be the sum of all 3. It would be 3 seperate instances of $total:$total = $x + null + null;$total = null + $y + null;$total = null + null + $z;unless you were to like, idk, setup some session variables or something. that might work the way you want it. Quote Link to comment https://forums.phpfreaks.com/topic/11416-php-wajax/#findComment-42852 Share on other sites More sharing options...
joeyjgarcia Posted June 7, 2006 Author Share Posted June 7, 2006 Cool! Seems very straight forward.I was thinking of creating a list of websites that I link to, I may want to select about 10 of them and then send the urls to my php page to ask Google about the page rank for each one. So you are saying that if I make 10 requests (for 10 selected urls), php won't know the difference and the AJAX will update the web page as the results come back in from the php one at a time.BTW, I am aware of the daily limit that Google puts on their API requests.Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/11416-php-wajax/#findComment-42872 Share on other sites More sharing options...
.josh Posted June 7, 2006 Share Posted June 7, 2006 [!--quoteo(post=381073:date=Jun 7 2006, 12:30 PM:name=joeyjgarcia)--][div class=\'quotetop\']QUOTE(joeyjgarcia @ Jun 7 2006, 12:30 PM) [snapback]381073[/snapback][/div][div class=\'quotemain\'][!--quotec--] So you are saying that if I make 10 requests (for 10 selected urls), php won't know the difference and the AJAX will update the web page as the results come back in from the php one at a time.[/quote]if you program your ajax/js that way, then yes. php will treat each of the 10 ajax postings just like it would treat clicking a normal submit button 10 times. Quote Link to comment https://forums.phpfreaks.com/topic/11416-php-wajax/#findComment-42892 Share on other sites More sharing options...
Barand Posted June 7, 2006 Share Posted June 7, 2006 You could also try something like this (PHP5)[code]<?php $xml = simplexml_load_file('http://www.somedomain.com/somepage.php'); $xsl = simpleXML_load_file('myformat.xsl'); $proc = new XsltProcessor(); $proc->importStylesheet($xsl); $newxml = $proc->transformToDoc($xml); print $newxml->saveXML();?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/11416-php-wajax/#findComment-42912 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.