ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" );
});
+window.foobar = null;
+window.testFoo = undefined;
+
test("jQuery.ajax - dataType html", function() {
expect(5);
stop();
- window.foobar = null;
- window.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' );
- // Cleanup the global namespace
- delete window.foobar;
- delete window.testFoo;
-
start();
};
expect(6);
equals( jQuery('#form').serialize(),
- "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2",
+ "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2",
'Check form serialization as query string');
equals( jQuery('#form :input').serialize(),
- "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2",
+ "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2",
'Check input serialization as query string');
equals( jQuery('#testForm').serialize(),
'Check input serialization as query string');
equals( jQuery('#form, #testForm').serialize(),
- "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
+ "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
'Multiple form serialization as query string');
equals( jQuery('#form, #testForm :input').serialize(),
- "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
+ "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
'Mixed form/input serialization as query string');
});
equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")");
jQuery("#foo").unbind('ajaxError');
- delete window.foobar;
start();
});
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');
- // Cleanup the global namespace
- delete window.foobar;
- delete window.testFoo;
-
start();
};
jQuery('#first').load(url('data/test.html'), function() {
test("load(String, Function) - check file with only a script tag", function() {
expect(3);
stop();
- window.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' );
- // Cleanup the global namespace
- delete window.testFoo;
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' );
- delete window.foobar;
setTimeout(start, 100);
});
});
expect(1);
stop();
jQuery.getScript(url("data/test.js"), function(){
- delete window.foobar;
start();
});
});
stop();
- window.foobar = null;
jQuery.ajax({
url: base + "data/test.js",
dataType: "script",
success: function(data){
ok( foobar, "Script results returned (GET, no callback)" );
- delete window.foobar;
start();
}
});
stop();
- window.foobar = null;
jQuery.ajax({
url: base + "data/test.js",
type: "POST",
success: function(data, status){
ok( foobar, "Script results returned (GET, no callback)" );
equals( status, "success", "Script results returned (GET, no callback)" );
- delete window.foobar;
start();
}
});
stop();
- window.foobar = null;
jQuery.ajax({
url: base + "data/test.js",
dataType: "script",
success: function(data){
ok( foobar, "Script results returned (GET, no callback)" );
- delete window.foobar;
start();
}
});
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();
});
});