I've got some jQuery which posts two variables to a php script. The PHP is very simple and simply returns a string based on what it's given, i.e. 'update successful' which I'd like to use in some way on the page.
The first time I click I get an alert saying 'undefined', any further clicks and everything works fine. Pretty sure I'm not far off but I can't work out this problem!
I've used firebug and the data is posted and the correct response is received on all attempts.
$(document).ready(function(){
$('#updatehol').click(function() {
additions = $('#additions').attr('value');
deductions = $('#deductions').attr('value');
datastring = 'additions='+ additions +'&deductions='+ deductions;
$.ajax({
type: "POST",
data: datastring,
url: "doadjust.php",
complete: function(data) {
alert(data.responseText);
}
});
});
});