Несколько Summernote Style, вызывая 403 ошибкиJavascript

Форум по Javascript
Ответить
Anonymous
 Несколько Summernote Style, вызывая 403 ошибки

Сообщение Anonymous »

Проблема: < /h1>
Я использую приборную панель Adminlte3 для разработки редактора Summernote. В моем разделе «Настройки я использую редактор Summernote» для добавления UpdateAppmsg, политики конфиденциальности, условий и условий и о нас. В этой форме я пытаюсь отправить свои данные через Ajax. ). < /p>

Без стиля он отлично добавляет значение < /li>
Добавить значения в стиль для одного Summernote, тогда это Работа нормально < /li>
< /ul>
Однако любое Summernote, сохраненное после этого, имеет такую ​​же ошибку, даже если я пытался обновить только один редактор < /p>
index.blade.php < /p>
@extends('layouts.app')

@section('content')


@csrf



Save Changes




//other fields

{{-- summernote1 section --}}


Update App Message



{{ $data->updateAppMessage ?? '' }}





{{-- summernote2 section --}}


About Us



{{ $data->aboutUs ?? '' }}







{{-- summernote3 --}}


Privacy Policy



{{ $data->privacyPolicy ?? '' }}





{{-- summnernote4 --}}


Terms And Conditions



{{ $data->termsCond ?? '' }}











function summnernote() {
$('.summernote').each(function() {
$(this).summernote({
placeholder: 'Add the text...',
tabsize: 2,
height: 200,
dialogsInBody: true,
dialogsFade: false,
disableDragAndDrop: true,
tooltip: false,
toolbar: [
// Customize the toolbar by removing the 'color' option which includes highlight
['style', ['style']],
['fontsize', ['fontsize']],
// ['color', ['color']],
['font', ['bold', 'italic', 'underline', 'clear']],
['fontname', ['fontname']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['insert', ['link']],
['view', ['fullscreen','help']]
],
fontSizes: [ '11', '13', '15', '17', '19', '21', '25', '30', '36'],
callbacks: {
onPaste: function (e) {
var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text');
e.preventDefault();
document.execCommand('insertText', false, bufferText);
}
}
});
});
}

function validateForm() {
let isValid = true;
const requiredFields = $('input[required]');
let firstInvalidField = null;

requiredFields.each(function() {
if (!$(this).val()) {
isValid = false;
if (!firstInvalidField) {
firstInvalidField = $(this); // Store the first invalid field
}
}
});

if (!isValid && firstInvalidField) {
// Open the collapse div of the first invalid field
firstInvalidField.closest('.collapse').collapse('show');
// Scroll to the first invalid field for better UX
$('html, body').animate({
scrollTop: firstInvalidField.offset()
}, 500);
}

return isValid;
}



@section('page-scripts')


var data = @json($data);

$(document).ready(function() {

summnernote();

if(!validateForm()){

showAlert('error' , 'Please fill all the required field.');
return false;

} else {
// Handle the confirmation button click
$('#formAppSetting').on('submit', function(event) {
event.preventDefault();

let formData = new FormData(this);
formData.append('_token', '{{ csrf_token() }}');

for (var pair of formData.entries()) {
console.log(pair[0] + '========> ' + pair[1]);
}

$.ajax({
url: $(this).attr('action'),
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function(response) {
showAlert('success', response.message);
$('#save-btn').prop('disabled', false);
$('#save-btn').text('Save Settings');

const appName = response.data.appName; // Assuming the response includes the updated app name
const placeholder = response.data.userPlaceholder;

if (appName) {
$('.app-name, .header-app-name').text(appName); // Adjust the selector to target your app name element
document.title = `${appName} Admin Panel`; // Update the page title if necessary
}

if (placeholder) {
$('link[rel="icon"]').attr('href', `{{ asset('storage') }}/${placeholder}`);
}

},
error: function(xhr) {
$('#save-btn').prop('disabled', false);
$('#save-btn').text('Save Settings');
var errorMessage = xhr.responseJSON?.message || 'An error occurred. Please try again.';
showAlert('error', errorMessage);

$('#formAppSetting')[0].reset();

$('.summernote').each(function() {
var textareaId = $(this).attr('name');
if (data[textareaId]) {
$(this).summernote('code', data[textareaId]); // Keep HTML content intact
}

});

setInterval(function() {
// Reset checkbox values to default state
$('input[type="checkbox"]').each(function() {
$(this).prop('checked', $(this).prop('defaultChecked'));
});
}, 1300);
},
});

});

}

});

@endsection

@endsection

< /code>
web.php
Route::get('/app-settings', [AppSettingController::class, 'index'])->name('app-settings.index');
Route::post('/app-settings-update', [AppSettingController::class, 'update'])->name('app-settings.update');
< /code>
Что я попробовал < /h1>
Я попробовал все, о чем я могу придумать, я могу консоли. Работы, и я не смог найти, в чем проблема.

Подробнее здесь: https://stackoverflow.com/questions/794 ... -403-error
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Javascript»