Solved

Problem loading content into div with jquery

Posted on 2011-03-14
10
374 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 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now