[jQuery] jQuery not working while loaded 2nd time in drupal
Hi,
i am working in a site made with drupal . there i am using ajax
through jQuery for a polling options.
the first time code runs nice ... as soon as some one submit one vote
the poll section is loaded with the new result.
now nothing works in that section.
i am having these two major issues :
1) if i comment out the $(document).ready ... line it doesnt work ,
even for the first time
2) as soon as the ajax is getting called i see two responses in
firebug .. one using POST method (in my code i have used this ) and
another using the GET method . The code is as follows:
$(document).ready(function(){
$("input[@id='edit-vote']").click(function(){
var posted_vote = $('input[@name=\'choice\']:checked').val();
if(posted_vote == null) {
alert('You must have to enter one choice first. Please check one of
the checkboxes.');
$('input[@name=\'choice\']').addClass('form-text required
error');
return false;
} else {
var form_nid = $('#edit-current-nid').val();
$("#div_poll").animate({opacity: 0.7}, 1500 );
$('#div_poll').html(loading_msg);
$.ajax({
type: "post",
url: req_path + "node/" + form_nid + "/ajax_poll",
data: "choice=" + posted_vote + "&op=Vote" + "&nid=" + form_nid,
success: function(msg){
$("#div_poll").animate({opacity: 1}, 1500 );
$('#div_poll').text(msg);
},
error: function (xmlhttp) {
alert('An HTTP error '+ xmlhttp.status +' occured.\n'+ uri);
}
});
}
});
});
any clue ?