I have a personal project which worked well and i want to add a new feature to it by including an ajax function but it looks like it is not called(checkRemaining). I even added the same behaviour as the previous ajax function(start) but still it doesn't execute, only the first one. Both functions call mysql query.
I am a working script which looks like this :
Label("Tx",9, Tx[0], 10);
Label("Tx",10, Tx[1], 10);
Label("Tx",17, Tx[5], 10);
Label("Tx",18, Tx[2], 10);
Label("Tx",19, Tx[3], 10);
Label("Tx",20, Tx[4], 12);
function Label($ty, $h, $el, $nr){
var x,remaining;
x = start($ty,$h);
remaining = checkRemaining($ty,$h);
if(x == $nr)
appendFull($el);
else{
$el.addEventListener("click", function(){
document.getElementById('tipe').value = $ty+ " " + $h;
// document.getElementById('loc').value = 'test';
window.scrollTo(0,document.body.scrollHeight);
undisableButton();
});
appendLabel($el);
}
}
The working function:
function start(z,o){
var result =0;
$.ajax({
type: "POST",
url: "CheckDate.php",
datatype: "html",
async: false,
data: {ty: z, h: o},
success: function(data) {
result = data;
}
});
return result;
}
The non working function :
function checkRemaining(z,o){
var result =0;
$.ajax({
type: "POST",
url: "CheckRemaining.php",
datatype: "html",
async: false,
data: {ty: z, h: o},
success: function(data) {
result = data;
}
});
return result;
}