I have a dataSend AJAX function that I am calling onclick
but it is not getting called.
I checked the it in the Inspector of my browser and it the click handler attached to it and yet when I put a breakpoint in the function using the Debugger, it never reaches there.
PHP/HTML Snippet (RAW)
<td onclick="dataSend('<?php echo $year;?>','12','<?php echo $rs->StudentId;?>');"><?php echo $count12[$rs->StudentId]."/248"; ?></td>
Now, this is cluttered because of the PHP, here's how it looks after being run in the browser.
After running on browser
<td class=" " onclick="dataSend('2015','02','186');">/224</td>
AJAX Snippet (Function)
function dataSend(year, month, studentid) {
parameters = 'StudentId='+studentid+'&Month='+month+'&Year='+year;
if(window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById('iframe').innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open('POST', 'attendancestu.php', true);
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.send(parameters);
}
FYI - This function is not inside any other function or trigger. It is not even inside $(document).ready();
I've written codes like this hundreds of times but I can't seem the figure out the problem here