开发者

Ajax only working first time

开发者 https://www.devze.com 2023-04-03 07:20 出处:网络
http://jsfiddle.net/tigreton/JGNmK/ You can see in the fiddle the code. It loads the #mod-pregunta and #mod-respuesta divs well. And开发者_StackOverflow the link too. But if I click it one more time

http://jsfiddle.net/tigreton/JGNmK/

You can see in the fiddle the code.

It loads the #mod-pregunta and #mod-respuesta divs well. And开发者_StackOverflow the link too. But if I click it one more time, it doesn't load anything. What do you think is happening? Thanks


Change

$(".vote1").html("<a href=\"\" title=\""+ id_pregunta + "-"+ id_respuesta + "-1\" class=\"vote1\" id=\""+ id_pregunta + "-"+ id_respuesta + "-1\" name=\"mod_up\">Aceptar</a>");

To

$(".vote1").replaceWith("<a href=\"\" title=\""+ id_pregunta + "-"+ id_respuesta + "-1\" class=\"vote1\" id=\""+ id_pregunta + "-"+ id_respuesta + "-1\" name=\"mod_up\">Aceptar</a>");

And use jQuery live to attach click event handler to the above anchor element.


Check out jQuery's live() function to help with this.


It can't load anything, because jsfiddle do not host mod_up_vote.php

However, on your server, try to use .live() or .delegate()

0

精彩评论

暂无评论...
验证码 换一张
取 消