bu hata var:Yakalanmayan TypeError: Özellik 'html' tanımsız bir okunamıyor - yalnızca belirli div AJAX sonrası cevap
Uncaught TypeError: Cannot read property 'html' of undefined
Ne oluşturmaya çalışıyorum her video için oylama sistemidir benim bir veritabanından sayfa. AJAX ile başarabildiğim tek sorun, cevabını doğru div sınıfında 'bu' olarak verememem, çünkü her divanda her divanda yayınlanacağı için - her videonun altında.
Kullanıcı oylama düğmesini tıklattıran üst divı tanımlamak ve yalnızca kendi alt botunu değiştirmek için çalışan bir çözüm gerekir.
LütfenLütfen yardım edin. İşte jQuery kodum. Burada
$(function() {
$(".vote").click(function() {
var id = $(this).attr("id");
var name = $(this).attr("name");
var dataString = 'id='+ id ;
var acdc = $('#ab').attr('class');
var potato = 'potato';
var parent = $(this);
if(name=='up')
{
$.ajax({
type: "POST",
url: "up_vote.php",
data: dataString,
cache: false,
success: function(html) { acdc.html(html);
}});
}
else
{
$(this).fadeIn(200).html('<img src="img/icon-down.png" align="absmiddle" style="height: 10px;width:10px;">');
$.ajax({
type: "POST",
url: "down_vote.php",
data: dataString,
cache: false,
success: function(html){
parent.parent().find('.this').html(html);
}});
}
return false;
});
});
video mesaj ile html div class'this' benim AJAX cevap asılması gereken yerlerde - ama sadece bir akım - php komut tüm spesifik kimliği, yalnızca video için bir oy ekler olarak !
<div class='botto'>
<div class='icon-wrap'>
<form action="blossom.php" method="post"><?php $id = $row["idv"]; ?>
<input type="hidden" id="id" value="<?php echo $row['idv']; ?>" />
<div cass='homesick'>
<button type='submit'name='up' style="background-color:transparent; border-color:transparent;outline: none; " class='icon vote' name="up"><img src='img/thumbsup.png' alt='up' name='up' class='icon vote icon-up' id="<?php echo $row['idv']; ?>" ></button>
<span class='number-vote this'>
<?php
echo $row['votev'];
?></span>
<button type='submit' name='down' style="background-color:transparent; border-color:transparent;outline: none; " class="vote" name="down"><img src='img/icon-down.png' alt='down' class='icon icon-down vote' id="<?php echo $row['idv']; ?>"></button>
</div>
</form>
</div>
</div>
nedir ] (http://stackoverflow.com/questions/36358422/pass-response-of-ajax-only-to-current-div-among-an-array)? –
HTML'nizde 'id = 'ab'' yoktur,' $ ("# ab") nedir? Attr (' class ') 'döndürmesi gerekiyor? – Barmar
video.php: 576 Türlenmemiş TypeError: acdc.html burada ne yazıyor bir işlev değil - ekledim >>>> '> Php echo $ row [' votev ']; ?> ve >>> var acdc = $ ('. Sayı-oy') attr ('id'); –