[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Problem loading content into div with jquery

Posted on 2011-03-14
10
Medium Priority
?
385 Views
Last Modified: 2012-05-11
I have the following that works in firefox, but not in IE.  The idea is to load two separate files into two separate divs with the one click.

      $(function(){      
            $('.loadcomp').click(function(){
            $("#thebody").html('<p><img src="../images/loading.png"  /></p>');
             $("#thebody").load(this.href);
             $("#innerindex").load('theindex.php');
            return false;
        });
0
Comment
Question by:debbieau1
  • 5
  • 5
10 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 35133587
Try :

$(function(){      
     $('.loadcomp').click(function(e){
         e.preventDefault();
         $("#thebody").html('<p><img src="../images/loading.png"  /></p>');
         $("#thebody").load(this.href);
         $("#innerindex").load('theindex.php');
         return false;
     });
});

Open in new window

0
 
LVL 1

Author Comment

by:debbieau1
ID: 35133691
Didn't work I'm afraid.  It actually broke the other links.  Instead of loading into a div, it tried to load each as a new page and not into the div.  Not sure what the e.preventDefault does but it didn't work in my case.
0
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 35133722
its seems you're writing over your code so it stop working
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:debbieau1
ID: 35133748
I don't understand could you explain some more.  Also can you please explain what the e.preventDefault does.   I have seen .click(function(e before but not clear on what it is for.
0
 
LVL 1

Author Comment

by:debbieau1
ID: 35133796
Because of your comments, I did manage to fix it by using previous code.  I was rewriting the function elsewhere it seemed.  Could you please explain the .click(function(e) please
0
 
LVL 1

Author Comment

by:debbieau1
ID: 35133799
because of your comment I was able to fix it using my original code.  I was rewriting the function.  Could you please still explain the .click(function(e) so I understand this
0
 
LVL 83

Expert Comment

by:leakim971
ID: 35133813
you put return false line 7, you know what happen ;)
preventDefault do more : http://api.jquery.com/event.preventDefault/

Else check this, you write over the script itself

<div id="Homer">
<script>
      //ready ?
      $("#Homer").load("donuts.php");
      // lucky if it run
      // lucky if it run
      // lucky if it run
      // lucky if it run
</script>
</div>

Open in new window


It is just a supposition, because I did not see your page...
0
 
LVL 83

Expert Comment

by:leakim971
ID: 35133816
good news ! thanks for the points!
0
 
LVL 1

Author Comment

by:debbieau1
ID: 35133844
thanks very much.  sorry for the double posting (windows crashed at time and thought it didn't get posted).
0
 
LVL 83

Expert Comment

by:leakim971
ID: 35133854
function(e)

e is the event object
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
This article discusses how to implement server side field validation and display customized error messages to the client.
Integration Management Part 2
Loops Section Overview
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question