Jump to content

loading php pages in order through ajax


Recommended Posts

I'm using the following script to load information into a div.  It works fine expect I want to make it do more and can't figure it out.

function loadingAjax(div_id) {
      var divIdHtml = $("#"+div_id).html();
           type: "POST",
           url: "testmash.php?tag=<? echo $ptag; ?>",
           data: "tag=John&id=28",
           beforeSend: function() {
			  $('#message').html("Importing Profile Information");
           success: function(msg) {
              $("#"+div_id).html(divIdHtml + msg);
			  $('#message').html("Successfly Imported Information");


So I got 3 or 4 php pages that access a api.  I want each page to process then return the message into my div.  So I could either combine all my php pages into one page and have the message get returned depending on what function the php is running or load them one by one.  I'm not sure how to do that.  When page one is loading I want it to say something like Importing Page 1 details when it gets done I want it to say successfully imported page 1 details then below that says importing page 2 details, so by the time the fourth page is getting processed it will say


Successfully Imported Page 1

Successfully Imported Page 2

Successfully Imported Page 3

Importing Page 4


Sorry this is hard for me to explain I hope someone can help.  Thanks ahead of time

Link to comment
Share on other sites

Hm, okay, assuming you have your PHP code adjusted a bit already by adding an additional GET parameter (let's call it "p", for page).


for(var i = 1; i <= 4; i++) {
url: "testmash.php?tag=<?php echo $ptag; ?>",
data: "tag=<?php echo $ptag; ?>&id=<?php echo $id; ?>&p="+i
// carry on with the rest... I'll get to explaining the PHP parts
So far the JavaScript (with a little support from PHP), for the PHP side, you need to check the directory of the file by doing something like readdir($dir), then do what you are trying to implement with your PHP right now (I cannot elaborate on what to do right now because you never actually posted your testmash.php, but that's okay - just look up the file functions PHP offers you).
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.

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.