Fix pb with ajaxonoff

This commit is contained in:
Laurent Destailleur 2026-03-24 20:49:49 +01:00
parent 5a0a914581
commit c8be6609a2
2 changed files with 29 additions and 7 deletions

View file

@ -111,7 +111,7 @@ if (preg_match('/stat[u][st]$/', $field) || ($field == 'evenunsubscribe' && $obj
top_httphead();
print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Registering new values
if (($action == 'set') && !empty($id)) { // Test on permission already done in header according to object and field.

View file

@ -811,8 +811,15 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input =
element: \''.dol_escape_js((empty($object->module) || $object->module == $object->element) ? $object->element : $object->element.'@'.$object->module).'\',
id: \''.((int) $object->id).'\',
token: \''.currentToken().'\'
},
function() {
}).done(
function(response) {
try {
var data = JSON.parse(response);
console.log(data);
} catch (e) {
console.log(response);
}
$("#set_'.$htmlname.'_'.$object->id.'").hide();
$("#del_'.$htmlname.'_'.$object->id.'").show();
// Enable another element
@ -830,7 +837,11 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input =
$("#" + value).show();
});
}
});
}).fail(
function(response) {
alert(response.responseText);
}
);
});
// Del constant
@ -843,8 +854,15 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input =
element: \''.dol_escape_js((empty($object->module) || $object->module == $object->element) ? $object->element : $object->element.'@'.$object->module).'\',
id: \''.((int) $object->id).'\',
token: \''.currentToken().'\'
},
function() {
}).done(
function(response) {
try {
var data = JSON.parse(response);
console.log(data);
} catch (e) {
console.log(response);
}
$("#del_'.$htmlname.'_'.$object->id.'").hide();
$("#set_'.$htmlname.'_'.$object->id.'").show();
// Disable another element
@ -862,7 +880,11 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input =
$("#" + value).hide();
});
}
});
}).fail(
function(response) {
alert(response.responseText);
}
);
});
});
</script>';