1.使用jquery的ajax提交请求,想要成功后执行一个函数,错误执行另一个函数。但是发现,无论请求成功还是失败,两个函数都会执行。请问这是为什么?
2.使用ajax请求了一个不存在的地址
`$.ajax({ type: 'get', url: '/asdfasdf', success: console.log('test'), error: console.log('wrong')});`
3.
4.
解决方案
回调函数包上function
$.ajax({ type: 'get', url: '/asdfasdf', success: function() {console.log('test')}, error: function() {console.log('wrong')}});