2
나는이 투표 시스템을 WordPress 설치에 사용하면 더 많은 정보가 있으면 하나의 게시물 만 있으면 제대로 작동하며, AJAX는 첫 번째 양식에 대해서만 게시합니다.
그래서 모든 게시물은 HTML 양식이 있습니다<form method="post" id="vote_<?php the_ID(); ?>" class="vote" name="vote">
<input type="hidden" id="vote_post_id" name="vote_post_id" value="<?php the_ID(); ?>" />
<input type="hidden" id="vote_count" name="vote_count" value="1" />
<span class="votes_count"><?php echo get_post_meta($post->ID, 'votes', true); ?></span>
<input type="submit" name="vote_up" class="vote_up" value="+1" />
</form>
을 그리고 여기에 jQuery의 :
$(function() {
$('form.vote').submit(function() {
var url = 'http://bla-bla.com/lib/';
post_id = $('input#vote_post_id').attr('value');
count = $('input#vote_count').attr('value');
form_id = $('form.vote').attr('id');
cast_vote = 'post_id=' + post_id + '&count=' + count;
original_count = $('span.votes_count').html();
new_value = parseInt(original_count) + 1;
//alert (cast_vote);return false;
$.ajax({
type: 'POST',
url: url + 'cast.php',
cache: false,
timeout: 10000,
data: cast_vote,
success: function(data){
$('form.vote').find('span.votes_count').fadeIn(1500, function() {
$(this).html(new_value);
});
$('form.vote').removeClass('vote').addClass('user_voted disabled');
}
});
return false;
});
});
그래서 나는이 만 submited 된 양식, 작업 할. 어떻게해야합니까?
.each()이 작동합니까?
감사합니다. –