I have a simple voting mechanism Im trying to block out. I got some help earlier and it works on its own but I'm trying to do it with an ajax callback - i get the returned data but the funciton isn't firing for some reason (although it works with a simple alert as the callback function) but it's not incrementing the numbers. Here's the simplified HTML
<form name="vote" id="vote" method="post" action="PHP/success.php">
<a class="vote">Good</a><input class="qty" type="text" name="qty" value="0" readonly="readonly" />
<a class="vote">Bad</a><input class="qty" type="text" name="qty" value="0" readonly="readonly" />
</form>
Here is the dummy PHP (PHP/success.php) that only performs an echo at this point
<?php
echo('ok');
?>
and my click function
$(".vote").click(function() {
$.ajax({
type: "POST",
url: "PHP/success.php",
success: function(data) {
if (data=="ok") {
var input = $(this).next(".qty");
input.val(parseFloat(input.val()) + 1);
} else {
alert('error');
}
}
});
});
again if i replace the (data="ok") var and function with an alert it works fine. thx
data, try$.trim(data) == 'ok'instead.Bad?$(this).next(".qty")will fail in that case.data?