-2
i diesen HTML Codebenötigen Sie einen Link mit der Taste
<a class="vote" action="id" id="1"> text </a>
und dies ist js Funktion dieser Schaltfläche haben zu erstellen.
$('.vote').click(function() {
var id = $(this).attr('id');
var competitionvotes = $(this).attr('action');
$.ajax({
type: "POST",
data: {
id: id,
competitionvotes: competitionvotes
},
url: 'http://'+window.location.hostname+'/ajax/vote_ajax',
success: function (data) {
if (data == 'success') {
$("."+id).css("display", "none");
$("."+id+'_v').css("display", "block");
}
if (data == 'fail') {
}
}
});
});
wie man richtig kriechende Verbindung herstellt? Beispiel domain.com/?action=id&id=1
(wird arbeiten, um dieses Beispiel nicht)
Funktioniert es nicht auf eine besondere Art und Weise? Handler wird nicht angerufen? Sie erhalten einen TypeError? Sie erhalten einen Netzwerkfehler? Der Browser setzt in Brand? –
Attribut "Aktion" auf ist nicht gültig HTML. – lukas84
Aktion ist eine Nummer Beispiel ist ID = 20 & competitionvotes = 1 – user3555881