Rushyo Posted April 3, 2006 Share Posted April 3, 2006 I've got an AJAX engine which sends through an XML document to a PHP script, which then parses it into a set of urls like below:loadpage.php?example=blehloadmenu.php?example=pootNow, to the important bit... how can I load up more than one url at a time? I want to run loadpage.php and loadmenu.php and get them both to send data back to the client. I'm not asking for an 'alternative' method I simply need to know how to do this, if it is possible.One plausible method is if PHP allows you to send HTTP requests to both pages... like so:MakeRequest("loadpage.php?example=bleh");MakeRequest("loadmenu.php?example=poot");Obviously I can't use the header() function since I need to load two scripst from one script... and I can't change the header twice.NOTE: My server using PHP 4. Quote Link to comment Share on other sites More sharing options...
yellow1912 Posted April 3, 2006 Share Posted April 3, 2006 I think you can do it only 1 by 1 (PHP is not multi-threaded, is it?). But maybe Im wrong.If you want to do it it 1 by 1, then use include or require. Quote Link to comment Share on other sites More sharing options...
Rushyo Posted April 3, 2006 Author Share Posted April 3, 2006 that only includes it, it doesn't give it a whole new set of POST/GET data to work with.I was thinking something along the lines of CURL... but that might actually be available on my shared hosting. Quote Link to comment Share on other sites More sharing options...
yellow1912 Posted April 3, 2006 Share Posted April 3, 2006 You can, I did it before, just include(loadmenu.php?example=poot);If you want to pass by POST then you can use curl [code]// SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'linkkkkk'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, "login=something&password=somwthing);[/code] Quote Link to comment Share on other sites More sharing options...
Rushyo Posted April 3, 2006 Author Share Posted April 3, 2006 Tried the include approach... it executed neither of the scripts.Ammendum: I figure CURL won't work because it operates in the same way 'header' does, it tells the user's browser to execute the request, which I believe won't work with AJAX since it points the user's browser away from the initial page.I'll have a try though Quote Link to comment Share on other sites More sharing options...
yellow1912 Posted April 3, 2006 Share Posted April 3, 2006 Tell me what result do you expect from calling the script? You want some parameters returned or something?for curl set curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); --> Then all the result will be return as a string instead of being displayed. Quote Link to comment Share on other sites More sharing options...
Rushyo Posted April 3, 2006 Author Share Posted April 3, 2006 Each of the two scripts are simply for testing and read:[code]<?php$ajax = "main|";$ajax = $ajax."Main";echo($ajax);?>[/code]and[code]<?php$ajax = "menu|";$ajax = $ajax."Menu";echo($ajax);?>[/code]What they should do is slot into the original HTML document like so:[code]<div id="main">Main</div><div id="menu">Menu</div>[/code]This is how the AJAX engine handles any responses from the scripts.If I make a call to one of them, it works fine but not if I try to call both (using the obviously flawed header method, which I knew would fail but it proves the rest of the code is working since it works in a single instance) Quote Link to comment Share on other sites More sharing options...
yellow1912 Posted April 3, 2006 Share Posted April 3, 2006 Pls read php.net:[a href=\"http://us2.php.net/manual/en/function.include.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.include.php[/a]Many good examples listed there. Anyway, Im so sleepy and gotta take a nap now, hope you can find the solution or someone can help.Cheers.err, just saw yor reply, try this:in your included script, echo everything you want to display:echo " blah blah blah --- This is the main";PS: If possible post your script here or pm me, at least part of it Quote Link to comment Share on other sites More sharing options...
Rushyo Posted April 3, 2006 Author Share Posted April 3, 2006 I can't help but feel that was meant as an insult to my intelligence.As I've already told you I've tried implementing include, if only just to shut you up after the first time I told you it wouldn't work. You quite clearly don't know how AJAX works, this isn't just slapping a web page on the client, it's about modifying one already on the client machine.[!--quoteo(post=361346:date=Apr 3 2006, 09:53 PM:name=yellow1912)--][div class=\'quotetop\']QUOTE(yellow1912 @ Apr 3 2006, 09:53 PM) [snapback]361346[/snapback][/div][div class=\'quotemain\'][!--quotec--]err, just saw yor reply, try this:in your included script, echo everything you want to display:echo " blah blah blah --- This is the main";PS: If possible post your script here or pm me, at least part of it[/quote][code]$ajax = "menu|";$ajax = $ajax."Menu";echo($ajax);[/code]That's what it already does... Quote Link to comment Share on other sites More sharing options...
yellow1912 Posted April 3, 2006 Share Posted April 3, 2006 Rushyo, I feel all asleep and I still trying to stay up to help you. And i never in my life insult anyone's intelligence or whatsoever, except mine.And I for one wouldnt get angry at someone who trying to help me, even if he is of use or not. You will never get any friend this way. Quote Link to comment Share on other sites More sharing options...
Rushyo Posted April 3, 2006 Author Share Posted April 3, 2006 "And I for one wouldnt get angry at someone who trying to help me, even if he is of use or not. You will never get any friend this way."If that person is implying I'm stupid, I wouldn't want to be friends with them.Forget it, I'll find some way around it myself. Quote Link to comment 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.