Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem loading content into div with jquery

Posted on 2011-03-14
10
Medium Priority
?
384 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 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 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

ASP.NET AJAX callbacks to web service are becoming very popular and unavoidable these days. The feel that the user gets when only a part of the page is updated without even hindering the UI is the advantage that the callbacks offer. The wait for the…
Today I am discussing AJAX problems in IE7 and I bet this will helps many guys out here who have problems with AJAX work. Lets start with the discovery of problem and then we will talk about its different solutions. My last two projects included …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

636 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