JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 25th, 2013, 04:46 PM
chofift chofift is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 28 chofift User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 2 m 41 sec
Reputation Power: 0
jQuery - Jquery function with Ajax

Hello

I was trying this:
Code:
<script> 
        $(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
});
    </script>
    <p>hhhhhhhhhh</p>


In a content I load with Ajax xmlhttprequest. The request only works in the home page, but not in the loaded content.

Any idea how come?
Thx. kr, C.

Reply With Quote
  #2  
Old January 25th, 2013, 11:20 PM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 658 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 8 h 2 m 36 sec
Reputation Power: 69
I think it's because the <p> tag element(s), that may be in your responseText (from your AJAX request); was not loaded in the DOM (basically when the parent document onload event occurred and I would assume; that the jQuery function is in your parent document). So you are only able to access the DOM onclick event of the <p> tag element(s); that are in your parent document; where (I am assuming)... your jQuery function resides. Now I maybe wrong; but this is my hypothesis.

Reply With Quote
  #3  
Old January 27th, 2013, 10:23 AM
chofift chofift is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 28 chofift User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 2 m 41 sec
Reputation Power: 0
Quote:
Originally Posted by web_loone08
I think it's because the <p> tag element(s), that may be in your responseText (from your AJAX request); was not loaded in the DOM (basically when the parent document onload event occurred and I would assume; that the jQuery function is in your parent document). So you are only able to access the DOM onclick event of the <p> tag element(s); that are in your parent document; where (I am assuming)... your jQuery function resides. Now I maybe wrong; but this is my hypothesis.


I solved it using the eval function.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > jQuery - Jquery function with Ajax

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap