简体   繁体   中英

How to catch jquery exception on ajax bad request?

I am saving user model like this:

this.model.save(data,{
                    success: function(user) {
                        console.log(user);
                    },
                    error: function() {
                        console.log("error");
                    }

                });

REST api returns 400 (Bad request) when for example user name is not unique). In console the "error" is displayed but BEFORE it there is jquery execption:

POST http://localhost/cms/users.json 400 (Bad Request)

how can I catch this exception so its not thrown to console?

The exceptions are showed up on console as a feature of the browser (plug-in in case of Firebug). You cannot turn it off and it doesn't affect your code flow in any manner. You should be ignoring it.

Check this for another similar q

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM