[SOLVED] Redirection to json response after resolving modal

Hi, I created a custom modal to submit a form to save to the database. The form itself works as intended, but after resolving the modal it redirects to a page that only shows a json array. Looking at the network tab of the browser’s development tools shows that the page is a application/json response.


With debugging I found that the controller method that saves the data to the database runs the code return $response->withJson([], <status code>);, where status code depends on if the data on the form was correct (400 if not, 200 if yes); and if I modify the array in this line its changes reflect on what appears on the page.

While processing the form on the server side in the controller, I add alert messages to be shown on the page, and after the empty page appears and I refresh those alerts appear on the page from which I open the modal.

This error doesn’t appear on other modals that come with the framework.

Thanks in advance.

It was an error of mine. When I copied the code for the event renderSuccess.ufModal I put it directly after loading the page, which meant it only ran at the start and thus when I created a modal later the event wasn’t attached.

So I only had to enclose the code in a function and have it called after each call of $("body").ufModal

Thanks for the attention.