?
Solved

Problem loading content into div with jquery

Posted on 2011-03-14
10
Medium Priority
?
383 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Hello World !, Thanks : My Sincere thanks to @Michael Male who encouraged me to write an article on this in my  blog (http://scribblejava.wordpress.com). Introduction:       There are several technical issues a developer may face in his…
The most up-to-date version of this article is on my Blog https://iconoun.com/blog/
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

752 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