1
0
forked from ScoDoc/ScoDoc
ScoDoc/app/static/js/abs_ajax.js

48 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-09-26 16:19:37 +02:00
// JS Ajax code for SignaleAbsenceGrSemestre
// Contributed by YLB
function ajaxFunction(mod, etudid, dat) {
2020-09-26 16:19:37 +02:00
var ajaxRequest; // The variable that makes Ajax possible!
try {
2020-09-26 16:19:37 +02:00
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e) {
2020-09-26 16:19:37 +02:00
// Internet Explorer Browsers
try {
2020-09-26 16:19:37 +02:00
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
2020-09-26 16:19:37 +02:00
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
2020-09-26 16:19:37 +02:00
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function () {
if (ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
document.getElementById("AjaxDiv").innerHTML = ajaxRequest.responseText;
2020-09-26 16:19:37 +02:00
}
}
ajaxRequest.open("POST", SCO_URL + "/Absences/doSignaleAbsenceGrSemestre", true);
ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
2021-02-26 13:54:16 +01:00
var oSelectOne = $("#abs_form")[0].elements["moduleimpl_id"];
var index = oSelectOne.selectedIndex;
var modul_id = oSelectOne.options[index].value;
2020-09-26 16:19:37 +02:00
if (mod == 'add') {
ajaxRequest.send("reply=0&moduleimpl_id=" + modul_id + "&abslist:list=" + etudid + ":" + dat);
2020-09-26 16:19:37 +02:00
}
if (mod == 'remove') {
ajaxRequest.send("reply=0&moduleimpl_id=" + modul_id + "&etudids=" + etudid + "&dates=" + dat);
2020-09-26 16:19:37 +02:00
}
}
// -----
function change_moduleimpl(url) {
document.location = url + '&moduleimpl_id=' + document.getElementById('moduleimpl_id').value;
}