lino_evolution
asked on
JQuery not getting called when Ajax is used
I am trying to call some JQuery functions from anchors that are passed through an AJAX method call. These anchors do not exist on the page until they are called from a ajax method which then populates a div tag with the new anchors.
The JQuery is not called. Is this because the JQuery functions are on the client side and the anchors are created on the server side then passed to the client.
Is there anyway to get this to work?
the code attached is the anchor that is passed during the call to the ajax method.
The JQuery is not called. Is this because the JQuery functions are on the client side and the anchors are created on the server side then passed to the client.
Is there anyway to get this to work?
the code attached is the anchor that is passed during the call to the ajax method.
<a href='communityDetails.aspx?mID=" & postID & "&action=bH&iframe=true&width=400&height=380' rel='prettyPhoto[iframes]'>" & Name & "</a>"
ASKER
Thanks leakim971, but can you clarify a bit more please.
Do I place the live click function on the anchor?
or do I put this in the custom JQuery library?
and how do I bind that click event to the particular prettyphoto function?
Do I place the live click function on the anchor?
or do I put this in the custom JQuery library?
and how do I bind that click event to the particular prettyphoto function?
ok, if you're using a plugin and you want to apply something on new link, just recall (or call) the function once you create the new link
so forget my previous answer
once you add the new link "recall" prettyphoto
so forget my previous answer
once you add the new link "recall" prettyphoto
ASKER
recall? can you elaborate on that?
how do i recall a function that is executed through an anchor? using rel='prettyPhoto[iframes]'
how do i recall a function that is executed through an anchor? using rel='prettyPhoto[iframes]'
$.ajax({ ...., success:function(data) {
blabla to add the new links
blabla to add the new links
blabla to add the new links
blabla to add the new links
$("a[rel^='prettyPhoto']") .prettyPho to(..blabl abla.); // here we "recall"
},
);
blabla to add the new links
blabla to add the new links
blabla to add the new links
blabla to add the new links
$("a[rel^='prettyPhoto']")
},
);
ASKER
I am creating and calling my AJAX method in a different way. I think that is why I am confused.
on my HTML page I have a div tag; <div id="BlogLoader"></div>
on
Page Load I call a javascript function that creates the XML Request Object and using the request to get the HTML code via a call to another page on the server.
function getCurrentBlogs()
{
*create request object
var userid = getQueryVariable('iUserID' );
request.open("get", "blog_data.aspx?data=g1&u= " + userid + "&anti-cache=" + new Date().getTime() , true);
request.onreadystatechange = handleBlogs;
request.send(null);
}
the function on the other end, at that blog_data page processes and returns HTML code to be displayed in the div tag, (which contains the anchors that calls pretty photo)
and sets the text to the DIV tag to the returned HTML
function handleBlogs()
{
if(request.readyState == 1)
{
$('#BlogLoader').html("<di v style='padding-top: 100px; text-align:center;'><img src='/imgs/loading_icon.gi f' /></div>");
}
if(request.readyState == 4){ //Finished loading the response
$('#BlogLoader').html(requ est.respon seText);
}
}
on my HTML page I have a div tag; <div id="BlogLoader"></div>
on
Page Load I call a javascript function that creates the XML Request Object and using the request to get the HTML code via a call to another page on the server.
function getCurrentBlogs()
{
*create request object
var userid = getQueryVariable('iUserID'
request.open("get", "blog_data.aspx?data=g1&u=
request.onreadystatechange
request.send(null);
}
the function on the other end, at that blog_data page processes and returns HTML code to be displayed in the div tag, (which contains the anchors that calls pretty photo)
and sets the text to the DIV tag to the returned HTML
function handleBlogs()
{
if(request.readyState == 1)
{
$('#BlogLoader').html("<di
}
if(request.readyState == 4){ //Finished loading the response
$('#BlogLoader').html(requ
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Brilliant! Thank you .. answered a bunch of other questions as well.
http://api.jquery.com/live/