I have a problem with ajax. I asked once about ajax but now my code can't send Data or even show alert. This code don't do anything. Only in web console in Data tab at "laravel-session" after click button to send it's changing data
$('#saveBtn').on('click', function (e) {
e.preventDefault();
alert("test");
$.ajax({
url: "/ress/Add",
method: "POST",
data: $('#addForm').serialize(),
dataType: 'text',
success: function (response) {
alert("test3");
}
});
alert("test2");
});
This code shows only alert with (test) and (test2) no (test3) even when in code is error function. I dig whole internet to find solution and still without results. (on submit) or other function doesn't work too. I can answer for any solutions if I tried this or other
It now send correctly But I think It's not open route file, because in route file with that I have to add some data to database
如果您获得 419 状态,则表示该路由受身份验证保护。
Please check error part of ajax, So that you can get what is the error.
$('#saveBtn').on('click', function (e) {
e.preventDefault();
alert("test");
$.ajax({
url: "/ress/Add",
method: "POST",
data: $('#addForm').serialize(),
dataType: 'text',
success: function (response) {
alert("test3");
},
error: function (err) {
alert("in error");
}
});
alert("test2");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.