Jump to content

Loading two scripts simultaneously


Rushyo

Recommended Posts

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=bleh
loadmenu.php?example=poot

Now, 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.
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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...
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

"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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.