{"action":"created","issue":{"url":"https://api.github.com/repos/yanatan16/nanoajax/issues/14","labels_url":"https://api.github.com/repos/yanatan16/nanoajax/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/yanatan16/nanoajax/issues/14/comments","events_url":"https://api.github.com/repos/yanatan16/nanoajax/issues/14/events","html_url":"https://github.com/yanatan16/nanoajax/issues/14","id":126112943,"number":14,"title":"200 returned on net::ERR_CONNECTION_REFUSED","user":{"login":"kjk","id":7935,"avatar_url":"https://avatars.githubusercontent.com/u/7935?v=3","gravatar_id":"","url":"https://api.github.com/users/kjk","html_url":"https://github.com/kjk","followers_url":"https://api.github.com/users/kjk/followers","following_url":"https://api.github.com/users/kjk/following{/other_user}","gists_url":"https://api.github.com/users/kjk/gists{/gist_id}","starred_url":"https://api.github.com/users/kjk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjk/subscriptions","organizations_url":"https://api.github.com/users/kjk/orgs","repos_url":"https://api.github.com/users/kjk/repos","events_url":"https://api.github.com/users/kjk/events{/privacy}","received_events_url":"https://api.github.com/users/kjk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-12T07:00:41Z","updated_at":"2016-01-13T22:07:14Z","closed_at":null,"body":"This is Chrome 47.0.2526.106 (64-bit) on Mac.\r\n\r\nWhen testing locally and when the server is not running, a request callback has code = 200 and empty responseText.\r\n\r\nThis issue is here:\r\n```\r\n  function cb(statusCode, responseText) {\r\n    return function () {\r\n      if (!called)\r\n        callback(req.status || statusCode,\r\n                 req.response || req.responseText || responseText,\r\n                 req)\r\n      called = true\r\n    }\r\n```\r\n\r\nIn my case `req.status` is 0 but is converted to 200 (`statusCode`) because it's called from: `if (req.readyState === 4) success()`. In console I see 'net::ERR_CONNECTION_REFUSED' error.\r\n\r\nNot sure what cases are where req.status 0 should be converted to something else. It seems to me this should be reported as error i.e. req.status should be passed as is to the callback.\r\n"},"comment":{"url":"https://api.github.com/repos/yanatan16/nanoajax/issues/comments/171452379","html_url":"https://github.com/yanatan16/nanoajax/issues/14#issuecomment-171452379","issue_url":"https://api.github.com/repos/yanatan16/nanoajax/issues/14","id":171452379,"user":{"login":"yanatan16","id":938655,"avatar_url":"https://avatars.githubusercontent.com/u/938655?v=3","gravatar_id":"","url":"https://api.github.com/users/yanatan16","html_url":"https://github.com/yanatan16","followers_url":"https://api.github.com/users/yanatan16/followers","following_url":"https://api.github.com/users/yanatan16/following{/other_user}","gists_url":"https://api.github.com/users/yanatan16/gists{/gist_id}","starred_url":"https://api.github.com/users/yanatan16/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yanatan16/subscriptions","organizations_url":"https://api.github.com/users/yanatan16/orgs","repos_url":"https://api.github.com/users/yanatan16/repos","events_url":"https://api.github.com/users/yanatan16/events{/privacy}","received_events_url":"https://api.github.com/users/yanatan16/received_events","type":"User","site_admin":false},"created_at":"2016-01-13T22:07:14Z","updated_at":"2016-01-13T22:07:14Z","body":"Thanks for the report. `req.status || statusCode` is supposed to catch `req.status == undefined`, not `req.status === 0`. I'll patch it to `req.status === undefined ? statusCode : req.status`"}}