forked from rebillar/site-accueil-insa
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
|
let ajaxurl = 'ajax_load.php';
|
||
|
|
||
|
$(document).ready(function () {
|
||
|
getMapInfo(getSelectedMap());
|
||
|
$(".save").click(function () {
|
||
|
let info = {};
|
||
|
info['title'] = $('#titleInput').val();
|
||
|
info['description'] = $('#descriptionInput').val();
|
||
|
let object = {
|
||
|
"function": 'save_map_info',
|
||
|
'selector': getSelectedMap(),
|
||
|
'info': info,
|
||
|
};
|
||
|
$.get(
|
||
|
ajaxurl,
|
||
|
object,
|
||
|
function (data) {
|
||
|
alert(data);
|
||
|
}
|
||
|
);
|
||
|
});
|
||
|
$('#mapSelect').on('change', function () {
|
||
|
getMapInfo(getSelectedMap());
|
||
|
});
|
||
|
});
|
||
|
|
||
|
function getSelectedMap() {
|
||
|
return $('#mapSelect').val();
|
||
|
}
|
||
|
|
||
|
function getMapInfo(selector) {
|
||
|
let object = {
|
||
|
"function": 'get_map_info',
|
||
|
'selector': selector,
|
||
|
};
|
||
|
$.get(
|
||
|
ajaxurl,
|
||
|
object,
|
||
|
function (data) {
|
||
|
console.log(data);
|
||
|
$('#titleInput').val(data[0]['title']);
|
||
|
$('#descriptionInput').val(data[0]['description']);
|
||
|
}
|
||
|
);
|
||
|
}
|