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.
精彩评论