开发者

CakePHP - Redirect to Cake error page from ajax request

开发者 https://www.devze.com 2023-04-12 17:24 出处:网络
I have an ajax edit button which edits a model.My model has a critical check for something that, if not present, throws a cakeError().

I have an ajax edit button which edits a model. My model has a critical check for something that, if not present, throws a cakeError().

When this happens, the response to the JS is just the HTML for the error page and obviousl开发者_如何学Goy this breaks my JS as well.

How would one go about redirecting to a proper Cake error page from the JS? Obviously I would need to pass it proper parameters about the error as well, which would come from the model.


You'll have to catch the error, return a json error message or status (its up to you how you do that) and redirect on the client side using javascript window.location.

Using AJAX you won't be able to trigger a redirect using php.

0

精彩评论

暂无评论...
验证码 换一张
取 消