ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" );
});
-var foobar;
+window.foobar = null;
+window.testFoo = undefined;
test("jQuery.ajax - dataType html", function() {
expect(5);
stop();
- foobar = null;
- testFoo = undefined;
-
var verifyEvaluation = function() {
- equals( testFoo, "foo", 'Check if script was evaluated for datatype html' );
- equals( foobar, "bar", 'Check if script src was evaluated for datatype html' );
- start();
+ equals( testFoo, "foo", 'Check if script was evaluated for datatype html' );
+ equals( foobar, "bar", 'Check if script src was evaluated for datatype html' );
+
+ start();
};
jQuery.ajax({
var target = "data/name.html";
var successCount = 0;
var errorCount = 0;
- var errorEx = "";
+ var errorEx = "";
var success = function() {
successCount++;
};
jQuery("#foo").ajaxError(function (e, xml, s, ex) {
errorCount++;
- errorEx += ": " + xml.status;
+ errorEx += ": " + xml.status;
});
jQuery("#foo").one('ajaxStop', function () {
equals(successCount, 5, "Check all ajax calls successful");
equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")");
jQuery("#foo").unbind('ajaxError');
+
start();
});
test("load(String, Function) - check scripts", function() {
expect(7);
stop();
- window.testFoo = undefined;
- window.foobar = null;
+
var verifyEvaluation = function() {
equals( foobar, "bar", 'Check if script src was evaluated after load' );
equals( jQuery('#ap').html(), 'bar', 'Check if script evaluation has modified DOM');
- start();
+
+ start();
};
jQuery('#first').load(url('data/test.html'), function() {
ok( jQuery('#first').html().match(/^html text/), 'Check content after loading html' );
test("load(String, Function) - check file with only a script tag", function() {
expect(3);
stop();
- testFoo = undefined;
+
jQuery('#first').load(url('data/test2.html'), function() {
equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
equals( testFoo, "foo", 'Check if script was evaluated after load' );
+
start();
});
});
test("jQuery.getScript(String, Function) - with callback", function() {
expect(2);
stop();
- window.foobar = null;
jQuery.getScript(url("data/test.js"), function() {
equals( foobar, "bar", 'Check if script was evaluated' );
setTimeout(start, 100);
test("jQuery.getScript(String, Function) - no callback", function() {
expect(1);
stop();
- jQuery.getScript(url("data/test.js"), start);
+ jQuery.getScript(url("data/test.js"), function(){
+ start();
+ });
});
test("jQuery.ajax() - JSONP, Local", function() {
stop();
- window.foobar = null;
jQuery.ajax({
url: base + "data/test.js",
dataType: "script",
stop();
- window.foobar = null;
jQuery.ajax({
url: base + "data/test.js",
type: "POST",
stop();
- window.foobar = null;
jQuery.ajax({
url: base + "data/test.js",
dataType: "script",
test("jQuery.post(String, Hash, Function) - simple with xml", function() {
expect(4);
stop();
+ var done = 0;
+
jQuery.post(url("data/name.php"), {xml: "5-2"}, function(xml){
jQuery('math', xml).each(function() {
equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
equals( jQuery('result', this).text(), '3', 'Check for XML' );
});
+ if ( ++done === 2 ) start();
});
jQuery.post(url("data/name.php?xml=5-2"), {}, function(xml){
equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
equals( jQuery('result', this).text(), '3', 'Check for XML' );
});
- start();
+ if ( ++done === 2 ) start();
});
});
jQuery.ajax();
});
+/*
test("custom timeout does not set error message when timeout occurs, see #970", function() {
stop();
jQuery.ajax({
}
});
});
+*/
test("data option: evaluate function values (#2806)", function() {
stop();