Right, I apologise well in advance for coming to you all with the most simple question you've probably ever seen. I can not for the life of me get my head around this.
PHP Code:
<?php
// this is ajax.php
$newRateNum = "1";
echo json_encode($newRateNum);
?>
PHP Code:
// this is index.php
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
// What we want to do here is
// Grab the ID
// Generate the variables
// Get a return from the PHP
// Update $('span#'+id+' a.rateNum') with that return
$(document).ready(function(){
$("a.rateDn").click(function() {
// we want to store the values from the form input box, then send via ajax below
$.ajax({
type: "POST",
url: "ajax.php",
data: "id="+this.parentNode.id+"&v=d",
success: function(){
$('a.rateNum').html($newRateNum);
}
});
return false;
});
});
</script>
<span class="rate" id="i79341"><a href="#" class="rateDn">[-]</a><a class="rateNum">0</a><a href="#" class="rateUp">[+]</a></span>
Seriously, clearly the problem is with the "$('a.rateNum').html($newRateNum);". All I want to know is, what the hell goes in the second set of brackets?
I simply want to replace the existing "0" in a.rateNum with whatever I output as $newRateNum in PHP.
Again, sorry because I know this is a question fit for a 6 year old - I just kind of suck at the whole client side coding
EDIT: Sticking an alert("whatever") in the success{} bit will do its job correctly, so I am getting that far for sure.