By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,282 Members | 1,526 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,282 IT Pros & Developers. It's quick & easy.

load() function in jquery not working

P: 1
hi there guys im currently working on a project with jquery...
the thing is.. i need to change the contents of a div named "sub2" with the contents of "pets.html"... i've read some tutorials and i thought the best way to do this is through the use of jquery... so here's my code...
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="jquery.js"></script>
  2. <script type="text/javascript">
  3. function contentDisp()
  4. {
  5. $.ajax({
  6. url : "pets.html",
  7. success : function (data) {
  8. $("#sub2").html(data);
  9. }
  10. });
  11. } </script>
  12.  
my image which is supposed to be clicked contains this
Expand|Select|Wrap|Line Numbers
  1. <a id="pets" onClick="contentDisp()"><img src="images/pets.png" id="pets"/></a>
  2.  
the code is working ., but when i transfer my codes to netbeans with Tomcat running the code didnt work ...

is there anyone here who knows what's wrong or what should i do with my code? thanks in advance
May 2 '11 #1
Share this Question
Share on Google+
2 Replies


100+
P: 1,059
get read the javascript error from the console and see what error you can see
May 9 '11 #2

P: 45
hi xiiopao
replace your function with the following
function contentDisp()
{
$('#sub2').load('pets.html');
}

this would work if you have loaded jquery file, else you would get it from here
http://code.jquery.com/jquery-1.7.1.min.js
Dec 23 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.