Skip to content
Advertisement

Ajax request keeps returning error function in Laravel

Good day guys. In my laravel application I’m trying to check if attendence for a particular date, subject, grade exists in my table. If so I have an if statement setup to display desire results based on what is returned.

I’m making the request with ajax but it seems like ajax keeps running the error function and I don’t seem to get any error code whatsoever or internal server error(500, 404, 403, etc) In my console the status return is 200 ok

here is my script:

JavaScript

Here is the controller the request is send to:

JavaScript

Now, if this code returns true:

JavaScript

The condition here runs and the right result is returned. But my else statement in the above does run but I don’t get the right result. This is the result I get:

There was an error please contact administrator

Which shows that it is this part of the ajax request that is running:

JavaScript

Surprisingly when I check the console this is what I see:

enter image description here

Which is exactly what I want but ajax is return otherwise. Am I doing something wrong?

Advertisement

Answer

JavaScript

Try this. I hope this will help you

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement