Solved

Problem loading content into div with jquery

Posted on 2011-03-14
10
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 82

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 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 35133722
its seems you're writing over your code so it stop working
0
Industry Leaders: 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 82

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 82

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 82

Expert Comment

by:leakim971
ID: 35133854
function(e)

e is the event object
0

Featured Post

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!

Question has a verified solution.

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

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

688 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