{"action":"created","issue":{"url":"https://api.github.com/repos/jasmine/jasmine-ajax/issues/159","repository_url":"https://api.github.com/repos/jasmine/jasmine-ajax","labels_url":"https://api.github.com/repos/jasmine/jasmine-ajax/issues/159/labels{/name}","comments_url":"https://api.github.com/repos/jasmine/jasmine-ajax/issues/159/comments","events_url":"https://api.github.com/repos/jasmine/jasmine-ajax/issues/159/events","html_url":"https://github.com/jasmine/jasmine-ajax/issues/159","id":165159068,"number":159,"title":"Request stub not immediately returning response on jquery load","user":{"login":"DavidGrinberg","id":13791262,"avatar_url":"https://avatars.githubusercontent.com/u/13791262?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidGrinberg","html_url":"https://github.com/DavidGrinberg","followers_url":"https://api.github.com/users/DavidGrinberg/followers","following_url":"https://api.github.com/users/DavidGrinberg/following{/other_user}","gists_url":"https://api.github.com/users/DavidGrinberg/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidGrinberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidGrinberg/subscriptions","organizations_url":"https://api.github.com/users/DavidGrinberg/orgs","repos_url":"https://api.github.com/users/DavidGrinberg/repos","events_url":"https://api.github.com/users/DavidGrinberg/events{/privacy}","received_events_url":"https://api.github.com/users/DavidGrinberg/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-07-12T19:23:32Z","updated_at":"2016-09-15T16:18:07Z","closed_at":"2016-09-15T16:18:07Z","body":"I have some code that, simplified, looks like - \r\n\r\n```\r\ninit = function(){\r\n  $(\"#foo\").load(\"some/path.html\", function(){\r\n      setSomeGlobalVar();\r\n  });\r\n}\r\n```\r\n\r\nI'm trying to test it with code like - \r\n\r\n```\r\ndescribe(\"foo test\", function(){\r\n  beforeEach(function(){\r\n    jasmine.Ajax.install();\r\n    jasmine.Ajax.stubRequest('some/path.html').andReturn({\r\n      contentType: 'text/plain',\r\n      responseText: '<bar/>'\r\n    });\r\n\r\n  afterEach(function(){\r\n    jasmine.Ajax.uninstall();\r\n  });\r\n\r\n  it(\"\", function(){\r\n      init();\r\n      expectGlobalVarToBeSet();//fails because load callback hasn't been called yet\r\n  }\r\n});\r\n```\r\n\r\nThis test is failing though. For some reason the stub does not respond until after the it block completes, when its too late for the expectation.\r\n\r\nWhy is this and how do I get the response to trigger synchronously?"},"comment":{"url":"https://api.github.com/repos/jasmine/jasmine-ajax/issues/comments/247376312","html_url":"https://github.com/jasmine/jasmine-ajax/issues/159#issuecomment-247376312","issue_url":"https://api.github.com/repos/jasmine/jasmine-ajax/issues/159","id":247376312,"user":{"login":"slackersoft","id":512724,"avatar_url":"https://avatars.githubusercontent.com/u/512724?v=3","gravatar_id":"","url":"https://api.github.com/users/slackersoft","html_url":"https://github.com/slackersoft","followers_url":"https://api.github.com/users/slackersoft/followers","following_url":"https://api.github.com/users/slackersoft/following{/other_user}","gists_url":"https://api.github.com/users/slackersoft/gists{/gist_id}","starred_url":"https://api.github.com/users/slackersoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slackersoft/subscriptions","organizations_url":"https://api.github.com/users/slackersoft/orgs","repos_url":"https://api.github.com/users/slackersoft/repos","events_url":"https://api.github.com/users/slackersoft/events{/privacy}","received_events_url":"https://api.github.com/users/slackersoft/received_events","type":"User","site_admin":false},"created_at":"2016-09-15T16:18:07Z","updated_at":"2016-09-15T16:18:07Z","body":"It sounds like this is an issue with jQuery and not Jasmine-Ajax, so I'm going to close this issue. Please let us know if you discover something that Jasmine-Ajax is doing that is causing issues like this.\r\n\r\nThanks for using Jasmine!"}}
{"actor":{"display_login":"slackersoft"}}