{"action":"created","issue":{"url":"https://api.github.com/repos/mootools/mootools-core/issues/2764","repository_url":"https://api.github.com/repos/mootools/mootools-core","labels_url":"https://api.github.com/repos/mootools/mootools-core/issues/2764/labels{/name}","comments_url":"https://api.github.com/repos/mootools/mootools-core/issues/2764/comments","events_url":"https://api.github.com/repos/mootools/mootools-core/issues/2764/events","html_url":"https://github.com/mootools/mootools-core/issues/2764","id":141334356,"number":2764,"title":"Shouldn't Request.JSON fire 'complete' event on JSON errors?","user":{"login":"lorenzos","id":245615,"avatar_url":"https://avatars.githubusercontent.com/u/245615?v=3","gravatar_id":"","url":"https://api.github.com/users/lorenzos","html_url":"https://github.com/lorenzos","followers_url":"https://api.github.com/users/lorenzos/followers","following_url":"https://api.github.com/users/lorenzos/following{/other_user}","gists_url":"https://api.github.com/users/lorenzos/gists{/gist_id}","starred_url":"https://api.github.com/users/lorenzos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorenzos/subscriptions","organizations_url":"https://api.github.com/users/lorenzos/orgs","repos_url":"https://api.github.com/users/lorenzos/repos","events_url":"https://api.github.com/users/lorenzos/events{/privacy}","received_events_url":"https://api.github.com/users/lorenzos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-03-16T16:55:23Z","updated_at":"2016-08-29T10:07:07Z","closed_at":null,"body":"When `Request.JSON` fails because response cannot be correctly parsed, the `'error'` event is fired. `'error'` is not an event inherit from `Request`, and is fired [here](https://github.com/mootools/mootools-core/blob/master/Source/Request/Request.JSON.js#L39):\r\n\r\n```javascript\r\ntry {\r\n\tjson = this.response.json = JSON.decode(text, this.options.secure);\r\n} catch (error){\r\n\tthis.fireEvent('error', [text, error]);\r\n\treturn;\r\n}\r\n```\r\n\r\nShouldn't it fire also the `'complete'` event? I use `'complete'`, for example, to hide progress indicators (like spinners), and for me the request is *completed* in case of errors too. Maybe my assumption is wrong, but then why the `'failure'` event [does it my way](https://github.com/mootools/mootools-core/blob/master/Source/Request/Request.js#L117) instead?\r\n\r\n```javascript\r\nonFailure: function(){\r\n\tthis.fireEvent('complete').fireEvent('failure', this.xhr);\r\n}\r\n```\r\n\r\n\r\n\r\n\r\n\r\n<bountysource-plugin>\r\n---\r\nWant to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/31955539-shouldn-t-request-json-fire-complete-event-on-json-errors?utm_campaign=plugin&utm_content=tracker%2F22067&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F22067&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/mootools/mootools-core/issues/comments/243085331","html_url":"https://github.com/mootools/mootools-core/issues/2764#issuecomment-243085331","issue_url":"https://api.github.com/repos/mootools/mootools-core/issues/2764","id":243085331,"user":{"login":"lorenzos","id":245615,"avatar_url":"https://avatars.githubusercontent.com/u/245615?v=3","gravatar_id":"","url":"https://api.github.com/users/lorenzos","html_url":"https://github.com/lorenzos","followers_url":"https://api.github.com/users/lorenzos/followers","following_url":"https://api.github.com/users/lorenzos/following{/other_user}","gists_url":"https://api.github.com/users/lorenzos/gists{/gist_id}","starred_url":"https://api.github.com/users/lorenzos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorenzos/subscriptions","organizations_url":"https://api.github.com/users/lorenzos/orgs","repos_url":"https://api.github.com/users/lorenzos/repos","events_url":"https://api.github.com/users/lorenzos/events{/privacy}","received_events_url":"https://api.github.com/users/lorenzos/received_events","type":"User","site_admin":false},"created_at":"2016-08-29T10:07:07Z","updated_at":"2016-08-29T10:07:07Z","body":"*(sorry, I accidentally clicked the wrong button)*"}}
{"actor":{"display_login":"lorenzos"}}