5

When I use a load() in load() function to load different elements from another page in one I have two request.

How can I make into one? Like this idea:

$mainContent.load(newHash + " .first"," .second", function() { });

Cause the problem I ran in is that a page that I loaded with a contact form sends twice cause I "thinks" it got loaded twice.

Heres the full code fragment:

if (newHash) {

            $claim.find("#claim").find("p").fadeTo(200,0);

            $mainContent.find(".maincontent").fadeTo(200,0, function() {

                $mainContent.fadeTo(0,0).load(newHash + " .maincontent", function() {

                        $claim.find("#claim").find("p").fadeTo(0,0, function() {

                            $claim.load(newHash + " #claim", function() {

                                $("#claim").fadeTo(0,0).fadeTo(200,1);

                                $mainContent.fadeTo(200,1);
                            });

                        });                
                });
            });   
        };

So how am I able to load multiple, different items with only one .load() request?

Is that possible?

Thank you.

Melros
  • 1,238
  • 2
  • 18
  • 34

3 Answers3

2

This works:

$mainContent.load(newHash + " .first, .second", function() { });

The answer is right here:

Jquery Multiple load in a DIV

Community
  • 1
  • 1
Melros
  • 1,238
  • 2
  • 18
  • 34
0

It would have to be an individual .load, then the function() can be a seperate function that is ran once all .loads are done. You have to focus on the function() part, rather than how you're attacking it. Or another option would be to do your multi-loading in the actual file, but i'm sure you've thought of that one. ;)

Here is one way you would do it, you can manipulate the i variable and while function accordingly:

    <script type="text/javascript">
    var i=0;
    while (i<=5)
      {
      document.write("The number is " + i);
      document.write("<br />");
      i++;
      }
    </script>
Control Freak
  • 12,965
  • 30
  • 94
  • 145
  • If you tell me what that means I'll definitely try that out. I just updated my question to demonstrate what I mean. Is is the right way anyway? – Melros Oct 04 '11 at 02:24
0

I realize it's a bit late for this answer, but I found a solution to this problem. No need to make several requests to the server.

$('.first').load(url+' .first > *', function(response){
 let res   = response
 $('.second').html($(res).find('.second').html())
})