skip to Main Content

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

POST

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

2

Answers


  1. If you get a 419 status that means that route is protected with authentication.

    Login or Signup to reply.
  2. 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");
        });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search