我正在尝试使用Jasmine为基本的jQuery AJAX请求编写一些BDD规范.我目前在独立模式下使用Jasmine(即通过SpecRunner.html).我已配置SpecRunner来加载jquery和其他.js文件.任何想法为什么以下不起作用?has_returned并不成真,甚至想到了"yuppi!" 警报显示正常.
describe("A jQuery ajax request should be able to fetch...", function() {
it("an XML file from the filesystem", function() {
$.ajax_get_xml_request = { has_returned : false };
// initiating the AJAX request
$.ajax({ type: "GET", url: "addressbook_files/addressbookxml.xml", dataType: "xml",
success: function(xml) { alert("yuppi!"); $.ajax_get_xml_request.has_returned = true; } });
// waiting for has_returned to become true (timeout: 3s)
waitsFor(function() { $.ajax_get_xml_request.has_returned; }, "the JQuery AJAX GET to return", 3000);
// TODO: other tests might check size of …Run Code Online (Sandbox Code Playgroud)