3 // Safari 3 randomly crashes when running these tests,
4 // but only in the full suite - you can run just the Ajax
5 // tests and they'll pass
6 //if ( !jQuery.browser.safari ) {
10 test("jQuery.ajax() - success callbacks", function() {
13 jQuery.ajaxSetup({ timeout: 0 });
17 jQuery('#foo').ajaxStart(function(){
18 ok( true, "ajaxStart" );
19 }).ajaxStop(function(){
20 ok( true, "ajaxStop" );
22 }).ajaxSend(function(){
23 ok( true, "ajaxSend" );
24 }).ajaxComplete(function(){
25 ok( true, "ajaxComplete" );
26 }).ajaxError(function(){
27 ok( false, "ajaxError" );
28 }).ajaxSuccess(function(){
29 ok( true, "ajaxSuccess" );
33 url: url("data/name.html"),
34 beforeSend: function(){ ok(true, "beforeSend"); },
35 success: function(){ ok(true, "success"); },
36 error: function(){ ok(false, "error"); },
37 complete: function(){ ok(true, "complete"); }
41 test("jQuery.ajax() - success callbacks - (url, options) syntax", function() {
44 jQuery.ajaxSetup({ timeout: 0 });
48 setTimeout(function(){
49 jQuery('#foo').ajaxStart(function(){
50 ok( true, "ajaxStart" );
51 }).ajaxStop(function(){
52 ok( true, "ajaxStop" );
54 }).ajaxSend(function(){
55 ok( true, "ajaxSend" );
56 }).ajaxComplete(function(){
57 ok( true, "ajaxComplete" );
58 }).ajaxError(function(){
59 ok( false, "ajaxError" );
60 }).ajaxSuccess(function(){
61 ok( true, "ajaxSuccess" );
64 jQuery.ajax( url("data/name.html") , {
65 beforeSend: function(){ ok(true, "beforeSend"); },
66 success: function(){ ok(true, "success"); },
67 error: function(){ ok(false, "error"); },
68 complete: function(){ ok(true, "complete"); }
73 test("jQuery.ajax() - success/error callbacks (remote)", function() {
75 var supports = jQuery.support.cors;
77 expect( supports ? 9 : 6 );
79 jQuery.ajaxSetup({ timeout: 0 });
83 setTimeout(function(){
84 jQuery('#foo').ajaxStart(function(){
85 ok( true, "ajaxStart" );
86 }).ajaxStop(function(){
87 ok( true, "ajaxStop" );
89 }).ajaxSend(function(){
90 ok( supports , "ajaxSend" );
91 }).ajaxComplete(function(){
92 ok( true, "ajaxComplete" );
93 }).ajaxError(function(){
94 ok( ! supports, "ajaxError" );
95 }).ajaxSuccess(function(){
96 ok( supports, "ajaxSuccess" );
100 // JULIAN TODO: Get an url especially for jQuery
101 url: "http://rockstarapps.com/test.php",
103 beforeSend: function(){ ok(supports, "beforeSend"); },
104 success: function( val ){ ok(supports, "success"); ok(supports && val.length, "data received"); },
105 error: function(_ , a , b ){ ok(!supports, "error"); },
106 complete: function(){ ok(true, "complete"); }
111 test("jQuery.ajax() - success callbacks (late binding)", function() {
114 jQuery.ajaxSetup({ timeout: 0 });
118 setTimeout(function(){
119 jQuery('#foo').ajaxStart(function(){
120 ok( true, "ajaxStart" );
121 }).ajaxStop(function(){
122 ok( true, "ajaxStop" );
124 }).ajaxSend(function(){
125 ok( true, "ajaxSend" );
126 }).ajaxComplete(function(){
127 ok( true, "ajaxComplete" );
128 }).ajaxError(function(){
129 ok( false, "ajaxError" );
130 }).ajaxSuccess(function(){
131 ok( true, "ajaxSuccess" );
135 url: url("data/name.html"),
136 beforeSend: function(){ ok(true, "beforeSend"); }
138 .complete(function(){ ok(true, "complete"); })
139 .success(function(){ ok(true, "success"); })
140 .error(function(){ ok(false, "error"); });
144 test("jQuery.ajax() - success callbacks (oncomplete binding)", function() {
147 jQuery.ajaxSetup({ timeout: 0 });
151 setTimeout(function(){
152 jQuery('#foo').ajaxStart(function(){
153 ok( true, "ajaxStart" );
154 }).ajaxStop(function(){
155 ok( true, "ajaxStop" );
156 }).ajaxSend(function(){
157 ok( true, "ajaxSend" );
158 }).ajaxComplete(function(){
159 ok( true, "ajaxComplete" );
160 }).ajaxError(function(){
161 ok( false, "ajaxError" );
162 }).ajaxSuccess(function(){
163 ok( true, "ajaxSuccess" );
167 url: url("data/name.html"),
168 beforeSend: function(){ ok(true, "beforeSend"); },
169 complete: function(xhr) {
171 .complete(function(){ ok(true, "complete"); })
172 .success(function(){ ok(true, "success"); })
173 .error(function(){ ok(false, "error"); })
174 .complete(function(){ start(); });
180 test("jQuery.ajax() - success callbacks (very late binding)", function() {
183 jQuery.ajaxSetup({ timeout: 0 });
187 setTimeout(function(){
188 jQuery('#foo').ajaxStart(function(){
189 ok( true, "ajaxStart" );
190 }).ajaxStop(function(){
191 ok( true, "ajaxStop" );
192 }).ajaxSend(function(){
193 ok( true, "ajaxSend" );
194 }).ajaxComplete(function(){
195 ok( true, "ajaxComplete" );
196 }).ajaxError(function(){
197 ok( false, "ajaxError" );
198 }).ajaxSuccess(function(){
199 ok( true, "ajaxSuccess" );
203 url: url("data/name.html"),
204 beforeSend: function(){ ok(true, "beforeSend"); },
205 complete: function(xhr) {
206 setTimeout (function() {
208 .complete(function(){ ok(true, "complete"); })
209 .success(function(){ ok(true, "success"); })
210 .error(function(){ ok(false, "error"); })
211 .complete(function(){ start(); });
218 test("jQuery.ajax() - success callbacks (order)", function() {
221 jQuery.ajaxSetup({ timeout: 0 });
227 setTimeout(function(){
229 url: url("data/name.html"),
230 success: function( _1 , _2 , xhr ) {
231 xhr.success(function() {
232 xhr.success(function() {
239 complete: function() {
240 strictEqual(testString, "ABCDE", "Proper order");
243 }).success(function() {
245 }).success(function() {
251 test("jQuery.ajax() - error callbacks", function() {
255 jQuery('#foo').ajaxStart(function(){
256 ok( true, "ajaxStart" );
257 }).ajaxStop(function(){
258 ok( true, "ajaxStop" );
260 }).ajaxSend(function(){
261 ok( true, "ajaxSend" );
262 }).ajaxComplete(function(){
263 ok( true, "ajaxComplete" );
264 }).ajaxError(function(){
265 ok( true, "ajaxError" );
266 }).ajaxSuccess(function(){
267 ok( false, "ajaxSuccess" );
270 jQuery.ajaxSetup({ timeout: 500 });
273 url: url("data/name.php?wait=5"),
274 beforeSend: function(){ ok(true, "beforeSend"); },
275 success: function(){ ok(false, "success"); },
276 error: function(){ ok(true, "error"); },
277 complete: function(){ ok(true, "complete"); }
281 test(".ajax() - headers" , function() {
283 // No multiple line headers in IE
284 expect( jQuery.browser.msie ? 2 : 4 );
289 url: url("data/headers.php"),
290 success: function( _1 , _2 , xhr ){
292 equals( xhr.getResponseHeader( "Single-Line" ) , "Hello World" , "Single line header" );
293 // No multiple line headers in IE
294 if ( ! jQuery.browser.msie ) {
295 // Each browser has its own unique way to deal with spaces after line breaks
296 // in multiple line headers, so we use regular expressions
297 ok( /^Hello\s+World$/.test( xhr.getResponseHeader( "Multiple-Line" ) ) , "Multiple line" );
298 ok( /^Hello\s+Beautiful\s+World$/.test( xhr.getResponseHeader( "Multiple-Multiple-Line" ) ) , "Multiple multiple line" );
302 error: function(){ ok(false, "error"); }
307 test(".ajax() - hash", function() {
311 url: "data/name.html#foo",
312 beforeSend: function( xhr, settings ) {
313 equals(settings.url, "data/name.html", "Make sure that the URL is trimmed.");
319 url: "data/name.html?abc#foo",
320 beforeSend: function( xhr, settings ) {
321 equals(settings.url, "data/name.html?abc", "Make sure that the URL is trimmed.");
327 url: "data/name.html?abc#foo",
328 data: { "test": 123 },
329 beforeSend: function( xhr, settings ) {
330 equals(settings.url, "data/name.html?abc&test=123", "Make sure that the URL is trimmed.");
336 test(".ajax() - 304", function() {
341 url: url("data/notmodified.php"),
342 success: function(){ ok(true, "304 ok"); },
343 // Do this because opera simply refuses to implement 304 handling :(
344 // A feature-driven way of detecting this would be appreciated
345 // See: http://gist.github.com/599419
346 error: function(){ ok(jQuery.browser.opera, "304 not ok "); },
347 complete: function(xhr){ start(); }
351 test(".load()) - 404 error callbacks", function() {
355 jQuery('#foo').ajaxStart(function(){
356 ok( true, "ajaxStart" );
357 }).ajaxStop(function(){
358 ok( true, "ajaxStop" );
360 }).ajaxSend(function(){
361 ok( true, "ajaxSend" );
362 }).ajaxComplete(function(){
363 ok( true, "ajaxComplete" );
364 }).ajaxError(function(){
365 ok( true, "ajaxError" );
366 }).ajaxSuccess(function(){
367 ok( false, "ajaxSuccess" );
370 jQuery("<div/>").load("data/404.html", function(){
371 ok(true, "complete");
375 test("jQuery.ajax() - abort", function() {
379 jQuery('#foo').ajaxStart(function(){
380 ok( true, "ajaxStart" );
381 }).ajaxStop(function(){
382 ok( true, "ajaxStop" );
384 }).ajaxSend(function(){
385 ok( true, "ajaxSend" );
386 }).ajaxComplete(function(){
387 ok( true, "ajaxComplete" );
390 var xhr = jQuery.ajax({
391 url: url("data/name.php?wait=5"),
392 beforeSend: function(){ ok(true, "beforeSend"); },
393 complete: function(){ ok(true, "complete"); }
396 equals( xhr.readyState, 1, "XHR readyState indicates successful dispatch" );
399 equals( xhr.readyState, 0, "XHR readyState indicates successful abortion" );
402 test("jQuery.ajax() - readyState (success)", function() {
405 jQuery.ajaxSetup({ timeout: 0 });
411 setTimeout(function(){
413 url: url("data/name.html"),
414 beforeSend: function( xhr ) {
415 xhr.onreadystatechange = function() {
416 control += xhr.readyState;
419 complete: function(){
420 setTimeout( function() {
421 equals( control , "1234" , "onreadystatechange was properly called" );
429 test("jQuery.ajax() - readyState (abort)", function() {
432 jQuery.ajaxSetup({ timeout: 0 });
438 setTimeout(function(){
440 jQuery.ajaxSetup({ timeout: 500 });
443 url: url("data/name.php?wait=5"),
444 beforeSend: function( xhr ) {
445 xhr.onreadystatechange = function() {
446 control += xhr.readyState;
449 complete: function( xhr ){
450 setTimeout( function() {
451 equals( control , "14" , "onreadystatechange was properly called" );
452 equals( xhr.readyState, 0 , "readyState is 0" );
460 test("jQuery.xhr() - reuse", function() {
463 jQuery.ajaxSetup({ timeout: 0 });
469 setTimeout(function(){
470 jQuery('#foo').ajaxStart(function(){
471 ok( true, "ajaxStart" );
472 }).ajaxStop(function(){
473 ok( true, "ajaxStop" );
475 }).ajaxSend(function(){
477 ok( true, "ajaxSend (" + number +")" );
478 }).ajaxComplete(function(){
479 ok( true, "ajaxComplete (" + number +")" );
480 }).ajaxError(function(){
481 ok( false, "ajaxError (" + number +")" );
482 }).ajaxSuccess(function(){
483 ok( true, "ajaxSuccess (" + number +")" );
487 url: url("data/name.html"),
488 beforeSend: function(){ ok(true, "beforeSend (1)"); },
489 success: function( _1 , _2 , xhr ){
490 ok(true, "success (1)");
491 xhr.complete(function() {
492 ok(true, "complete (1bis)");
494 xhr.open( "GET", url("data/name.html") );
495 xhr.success( function(){ ok(true, "beforeSend (2)"); } )
497 success: function(){ ok(true, "success (2)"); },
498 error: function(){ ok(false, "error (2)"); },
499 complete: function(){ ok(true, "complete (2)"); }
502 error: function(){ ok(false, "error (1)"); },
503 complete: function(){ ok(true, "complete (1)"); }
508 test("jQuery.xhr() - early binding", function() {
511 jQuery.ajaxSetup({ timeout: 0 });
516 .success( function(){ ok(true, "success"); } )
517 .error( function(){ ok(false, "error"); } )
518 .complete( function(){ ok(true, "complete"); start(); } )
519 .open( "GET", url("data/name.html") )
523 test("jQuery.xhr() - get native implementation", function() {
525 var xhr = jQuery.xhr(true);
527 ok( xhr.readyState !== undefined , "implements XMLHttpRequest" );
528 ok( ! jQuery.isFunction( xhr.success ) , "is not jQuery's abstraction" );
532 test("Ajax events with context", function() {
536 var context = document.createElement("div");
539 equals( this, context, e.type );
542 function callback(msg){
544 equals( this, context, "context is preserved on callback " + msg );
548 function nocallback(msg){
550 equals( typeof this.url, "string", "context is settings on callback " + msg );
554 jQuery('#foo').add(context)
561 url: url("data/name.html"),
562 beforeSend: callback("beforeSend"),
563 success: callback("success"),
564 error: callback("error"),
566 callback("complete").call(this);
569 url: url("data/404.html"),
571 beforeSend: callback("beforeSend"),
572 error: callback("error"),
573 complete: function(){
574 callback("complete").call(this);
576 jQuery('#foo').add(context).unbind();
579 url: url("data/404.html"),
580 beforeSend: nocallback("beforeSend"),
581 error: nocallback("error"),
582 complete: function(){
583 nocallback("complete").call(this);
594 test("jQuery.ajax context modification", function() {
602 url: url("data/name.html"),
604 beforeSend: function(){
607 complete: function() {
612 equals( obj.test, "foo", "Make sure the original object is maintained." );
615 test("jQuery.ajax() - disabled globals", function() {
619 jQuery('#foo').ajaxStart(function(){
620 ok( false, "ajaxStart" );
621 }).ajaxStop(function(){
622 ok( false, "ajaxStop" );
623 }).ajaxSend(function(){
624 ok( false, "ajaxSend" );
625 }).ajaxComplete(function(){
626 ok( false, "ajaxComplete" );
627 }).ajaxError(function(){
628 ok( false, "ajaxError" );
629 }).ajaxSuccess(function(){
630 ok( false, "ajaxSuccess" );
635 url: url("data/name.html"),
636 beforeSend: function(){ ok(true, "beforeSend"); },
637 success: function(){ ok(true, "success"); },
638 error: function(){ ok(false, "error"); },
639 complete: function(){
640 ok(true, "complete");
641 setTimeout(function(){ start(); }, 13);
646 test("jQuery.xhr() - disabled globals through xhr.send(data , false)", function() {
650 jQuery('#foo').ajaxStart(function(){
651 ok( false, "ajaxStart" );
652 }).ajaxStop(function(){
653 ok( false, "ajaxStop" );
654 }).ajaxSend(function(){
655 ok( false, "ajaxSend" );
656 }).ajaxComplete(function(){
657 ok( false, "ajaxComplete" );
658 }).ajaxError(function(){
659 ok( false, "ajaxError" );
660 }).ajaxSuccess(function(){
661 ok( false, "ajaxSuccess" );
665 .success(function(){ ok(true, "success"); })
666 .error(function(){ ok(false, "error"); })
667 .complete(function(){
668 ok(true, "complete");
669 setTimeout(function(){ start(); }, 13);
671 .open("GET", url("data/name.html")).send(undefined, false);
674 test("jQuery.ajax - xml: non-namespace elements inside namespaced elements", function() {
678 url: url("data/with_fries.xml"),
680 success: function(resp) {
681 equals( jQuery("properties", resp).length, 1, 'properties in responseXML' );
682 equals( jQuery("jsconf", resp).length, 1, 'jsconf in responseXML' );
683 equals( jQuery("thing", resp).length, 2, 'things in responseXML' );
689 test("jQuery.ajax - xml: non-namespace elements inside namespaced elements (over JSONP)", function() {
693 url: url("data/with_fries_over_jsonp.php"),
694 dataType: "jsonp xml",
695 success: function(resp) {
696 equals( jQuery("properties", resp).length, 1, 'properties in responseXML' );
697 equals( jQuery("jsconf", resp).length, 1, 'jsconf in responseXML' );
698 equals( jQuery("thing", resp).length, 2, 'things in responseXML' );
704 test("jQuery.ajax - HEAD requests", function() {
709 url: url("data/name.html"),
711 success: function(data, status, xhr){
712 var h = xhr.getAllResponseHeaders();
713 ok( /Date/i.test(h), 'No Date in HEAD response' );
716 url: url("data/name.html"),
717 data: { whip_it: "good" },
719 success: function(data, status, xhr){
720 var h = xhr.getAllResponseHeaders();
721 ok( /Date/i.test(h), 'No Date in HEAD response with data' );
730 test("jQuery.ajax - beforeSend", function() {
736 jQuery.ajaxSetup({ timeout: 0 });
739 url: url("data/name.html"),
740 beforeSend: function(xml) {
743 success: function(data) {
744 ok( check, "check beforeSend was executed" );
750 test("jQuery.ajax - beforeSend, cancel request (#2688)", function() {
752 var request = jQuery.ajax({
753 url: url("data/name.html"),
754 beforeSend: function() {
755 ok( true, "beforeSend got called, canceling" );
758 success: function() {
759 ok( false, "request didn't get canceled" );
761 complete: function() {
762 ok( false, "request didn't get canceled" );
765 ok( false, "request didn't get canceled" );
768 ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" );
771 test("jQuery.ajax - beforeSend, cancel request manually", function() {
773 var request = jQuery.ajax({
774 url: url("data/name.html"),
775 beforeSend: function(xhr) {
776 ok( true, "beforeSend got called, canceling" );
779 success: function() {
780 ok( false, "request didn't get canceled" );
782 complete: function() {
783 ok( false, "request didn't get canceled" );
786 ok( false, "request didn't get canceled" );
789 ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" );
792 window.foobar = null;
793 window.testFoo = undefined;
795 test("jQuery.ajax - dataType html", function() {
799 var verifyEvaluation = function() {
800 equals( testFoo, "foo", 'Check if script was evaluated for datatype html' );
801 equals( foobar, "bar", 'Check if script src was evaluated for datatype html' );
808 url: url("data/test.html"),
809 success: function(data) {
810 jQuery("#ap").html(data);
811 ok( data.match(/^html text/), 'Check content for datatype html' );
812 setTimeout(verifyEvaluation, 600);
817 test("serialize()", function() {
820 // Add html5 elements only for serialize because selector can't yet find them on non-html5 browsers
821 jQuery("#search").after(
822 '<input type="email" id="html5email" name="email" value="dave@jquery.com" />'+
823 '<input type="number" id="html5number" name="number" value="43" />'
826 equals( jQuery('#form').serialize(),
827 "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3",
828 'Check form serialization as query string');
830 equals( jQuery('#form :input').serialize(),
831 "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3",
832 'Check input serialization as query string');
834 equals( jQuery('#testForm').serialize(),
835 'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
836 'Check form serialization as query string');
838 equals( jQuery('#testForm :input').serialize(),
839 'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
840 'Check input serialization as query string');
842 equals( jQuery('#form, #testForm').serialize(),
843 "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
844 'Multiple form serialization as query string');
846 /* Temporarily disabled. Opera 10 has problems with form serialization.
847 equals( jQuery('#form, #testForm :input').serialize(),
848 "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&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=",
849 'Mixed form/input serialization as query string');
851 jQuery("#html5email, #html5number").remove();
854 test("jQuery.param()", function() {
857 equals( !jQuery.ajaxSettings.traditional, true, "traditional flag, falsy by default" );
859 var params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
860 equals( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
862 params = {someName: [1, 2, 3], regularThing: "blah" };
863 equals( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" );
865 params = {foo: ['a', 'b', 'c']};
866 equals( jQuery.param(params), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" );
868 params = {foo: ["baz", 42, "All your base are belong to us"] };
869 equals( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
871 params = {foo: { bar: 'baz', beep: 42, quux: 'All your base are belong to us' } };
872 equals( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
874 params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
875 equals( decodeURIComponent( jQuery.param(params) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=undefined&i[]=10&i[]=11&j=true&k=false&l[]=undefined&l[]=0&m=cowboy+hat?", "huge structure" );
877 params = { a: [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { b: [ 7, [ 8, 9 ], [ { c: 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { e: { f: { g: [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] };
878 equals( decodeURIComponent( jQuery.param(params) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" );
880 params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
881 equals( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" );
883 equals( decodeURIComponent( jQuery.param({ a: [1,2,3], 'b[]': [4,5,6], 'c[d]': [7,8,9], e: { f: [10], g: [11,12], h: 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." );
885 // Make sure empty arrays and objects are handled #6481
886 equals( jQuery.param({"foo": {"bar": []} }), "foo%5Bbar%5D=", "Empty array param" );
887 equals( jQuery.param({"foo": {"bar": [], foo: 1} }), "foo%5Bbar%5D=&foo%5Bfoo%5D=1", "Empty array param" );
888 equals( jQuery.param({"foo": {"bar": {}} }), "foo%5Bbar%5D=", "Empty object param" );
890 jQuery.ajaxSetup({ traditional: true });
892 var params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
893 equals( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
895 params = {someName: [1, 2, 3], regularThing: "blah" };
896 equals( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" );
898 params = {foo: ['a', 'b', 'c']};
899 equals( jQuery.param(params), "foo=a&foo=b&foo=c", "with array of strings" );
901 params = {"foo[]":["baz", 42, "All your base are belong to us"]};
902 equals( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
904 params = {"foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us"};
905 equals( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
907 params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
908 equals( jQuery.param(params), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure" );
910 params = { a: [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { b: [ 7, [ 8, 9 ], [ { c: 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { e: { f: { g: [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] };
911 equals( jQuery.param(params), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" );
913 params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" };
914 equals( decodeURIComponent( jQuery.param(params,false) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=undefined&i[]=10&i[]=11&j=true&k=false&l[]=undefined&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" );
916 params = { param1: null };
917 equals( jQuery.param(params,false), "param1=null", "Make sure that null params aren't traversed." );
920 test("synchronous request", function() {
922 ok( /^{ "data"/.test( jQuery.ajax({url: url("data/json_obj.js"), dataType: "text", async: false}).responseText ), "check returned text" );
925 test("synchronous request with callbacks", function() {
928 jQuery.ajax({url: url("data/json_obj.js"), async: false, dataType: "text", success: function(data) { ok(true, "sucess callback executed"); result = data; } });
929 ok( /^{ "data"/.test( result ), "check returned text" );
932 test("pass-through request object", function() {
936 var target = "data/name.html";
937 var successCount = 0;
940 var success = function() {
943 jQuery("#foo").ajaxError(function (e, xml, s, ex) {
945 errorEx += ": " + xml.status;
947 jQuery("#foo").one('ajaxStop', function () {
948 equals(successCount, 5, "Check all ajax calls successful");
949 equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")");
950 jQuery("#foo").unbind('ajaxError');
955 ok( jQuery.get(url(target), success), "get" );
956 ok( jQuery.post(url(target), success), "post" );
957 ok( jQuery.getScript(url("data/test.js"), success), "script" );
958 ok( jQuery.getJSON(url("data/json_obj.js"), success), "json" );
959 ok( jQuery.ajax({url: url(target), success: success}), "generic" );
962 test("ajax cache", function () {
969 jQuery("#firstp").bind("ajaxSuccess", function (e, xml, s) {
970 var re = /_=(.*?)(&|$)/g;
972 for (var i = 0; i < 6; i++) {
973 var ret = re.exec(s.url);
979 equals(i, 1, "Test to make sure only one 'no-cache' parameter is there");
980 ok(oldOne != "tobereplaced555", "Test to be sure parameter (if it was there) was replaced");
985 ok( jQuery.ajax({url: "data/text.php", cache:false}), "test with no parameters" );
986 ok( jQuery.ajax({url: "data/text.php?pizza=true", cache:false}), "test with 1 parameter" );
987 ok( jQuery.ajax({url: "data/text.php?_=tobereplaced555", cache:false}), "test with _= parameter" );
988 ok( jQuery.ajax({url: "data/text.php?pizza=true&_=tobereplaced555", cache:false}), "test with 1 parameter plus _= one" );
989 ok( jQuery.ajax({url: "data/text.php?_=tobereplaced555&tv=false", cache:false}), "test with 1 parameter plus _= one before it" );
990 ok( jQuery.ajax({url: "data/text.php?name=David&_=tobereplaced555&washere=true", cache:false}), "test with 2 parameters surrounding _= one" );
995 * The assertions expect that the passed-in object will be modified,
996 * which shouldn't be the case. Fixes #5439.
997 test("global ajaxSettings", function() {
1000 var tmp = jQuery.extend({}, jQuery.ajaxSettings);
1001 var orig = { url: "data/with_fries.xml" };
1004 jQuery.ajaxSetup({ data: {foo: 'bar', bar: 'BAR'} });
1006 t = jQuery.extend({}, orig);
1009 ok( t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending {}" );
1011 t = jQuery.extend({}, orig);
1012 t.data = { zoo: 'a', ping: 'b' };
1014 ok( t.url.indexOf('ping') > -1 && t.url.indexOf('zoo') > -1 && t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending { zoo: 'a', ping: 'b' }" );
1016 jQuery.ajaxSettings = tmp;
1020 test("load(String)", function() {
1022 stop(); // check if load can be called with only url
1023 jQuery('#first').load("data/name.html", start);
1026 test("load('url selector')", function() {
1028 stop(); // check if load can be called with only url
1029 jQuery('#first').load("data/test3.html div.user", function(){
1030 equals( jQuery(this).children("div").length, 2, "Verify that specific elements were injected" );
1035 test("load(String, Function) with ajaxSetup on dataType json, see #2046", function() {
1038 jQuery.ajaxSetup({ dataType: "json" });
1039 jQuery("#first").ajaxComplete(function (e, xml, s) {
1040 equals( s.dataType, "html", "Verify the load() dataType was html" );
1041 jQuery("#first").unbind("ajaxComplete");
1042 jQuery.ajaxSetup({ dataType: "" });
1045 jQuery('#first').load("data/test3.html");
1048 test("load(String, Function) - simple: inject text into DOM", function() {
1051 jQuery('#first').load(url("data/name.html"), function() {
1052 ok( /^ERROR/.test(jQuery('#first').text()), 'Check if content was injected into the DOM' );
1057 test("load(String, Function) - check scripts", function() {
1061 var verifyEvaluation = function() {
1062 equals( foobar, "bar", 'Check if script src was evaluated after load' );
1063 equals( jQuery('#ap').html(), 'bar', 'Check if script evaluation has modified DOM');
1067 jQuery('#first').load(url('data/test.html'), function() {
1068 ok( jQuery('#first').html().match(/^html text/), 'Check content after loading html' );
1069 equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
1070 equals( testFoo, "foo", 'Check if script was evaluated after load' );
1071 setTimeout(verifyEvaluation, 600);
1075 test("load(String, Function) - check file with only a script tag", function() {
1079 jQuery('#first').load(url('data/test2.html'), function() {
1080 equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
1081 equals( testFoo, "foo", 'Check if script was evaluated after load' );
1087 test("load(String, Object, Function)", function() {
1091 jQuery('<div />').load(url('data/params_html.php'), { foo:3, bar:'ok' }, function() {
1092 var $post = jQuery(this).find('#post');
1093 equals( $post.find('#foo').text(), '3', 'Check if a hash of data is passed correctly');
1094 equals( $post.find('#bar').text(), 'ok', 'Check if a hash of data is passed correctly');
1099 test("load(String, String, Function)", function() {
1103 jQuery('<div />').load(url('data/params_html.php'), 'foo=3&bar=ok', function() {
1104 var $get = jQuery(this).find('#get');
1105 equals( $get.find('#foo').text(), '3', 'Check if a string of data is passed correctly');
1106 equals( $get.find('#bar').text(), 'ok', 'Check if a of data is passed correctly');
1111 test("jQuery.get(String, Hash, Function) - parse xml and use text() on nodes", function() {
1114 jQuery.get(url('data/dashboard.xml'), function(xml) {
1116 jQuery('tab', xml).each(function() {
1117 content.push(jQuery(this).text());
1119 equals( content[0], 'blabla', 'Check first tab');
1120 equals( content[1], 'blublu', 'Check second tab');
1125 test("jQuery.getScript(String, Function) - with callback", function() {
1128 jQuery.getScript(url("data/test.js"), function() {
1129 equals( foobar, "bar", 'Check if script was evaluated' );
1130 setTimeout(start, 100);
1134 test("jQuery.getScript(String, Function) - no callback", function() {
1137 jQuery.getScript(url("data/test.js"), function(){
1142 test("jQuery.ajax() - JSONP, Local", function() {
1146 function plus(){ if ( ++count == 9 ) start(); }
1151 url: "data/jsonp.php",
1153 success: function(data){
1154 ok( data.data, "JSON results returned (GET, no callback)" );
1157 error: function(data){
1158 ok( false, "Ajax error JSON (GET, no callback)" );
1164 url: "data/jsonp.php?callback=?",
1166 success: function(data){
1167 ok( data.data, "JSON results returned (GET, url callback)" );
1170 error: function(data){
1171 ok( false, "Ajax error JSON (GET, url callback)" );
1177 url: "data/jsonp.php",
1180 success: function(data){
1181 ok( data.data, "JSON results returned (GET, data callback)" );
1184 error: function(data){
1185 ok( false, "Ajax error JSON (GET, data callback)" );
1191 url: "data/jsonp.php",
1194 success: function(data){
1195 ok( data.data, "JSON results returned (GET, data obj callback)" );
1198 error: function(data){
1199 ok( false, "Ajax error JSON (GET, data obj callback)" );
1205 url: "data/jsonp.php",
1207 jsonpCallback: "jsonpResults",
1208 success: function(data){
1209 ok( data.data, "JSON results returned (GET, custom callback name)" );
1212 error: function(data){
1213 ok( false, "Ajax error JSON (GET, custom callback name)" );
1220 url: "data/jsonp.php",
1222 success: function(data){
1223 ok( data.data, "JSON results returned (POST, no callback)" );
1226 error: function(data){
1227 ok( false, "Ajax error JSON (GET, data obj callback)" );
1234 url: "data/jsonp.php",
1237 success: function(data){
1238 ok( data.data, "JSON results returned (POST, data callback)" );
1241 error: function(data){
1242 ok( false, "Ajax error JSON (POST, data callback)" );
1249 url: "data/jsonp.php",
1252 success: function(data){
1253 ok( data.data, "JSON results returned (POST, data obj callback)" );
1256 error: function(data){
1257 ok( false, "Ajax error JSON (POST, data obj callback)" );
1264 url: "data/jsonp.php",
1266 beforeSend: function(){
1267 strictEqual( this.cache, false, "cache must be false on JSON request" );
1274 test("jQuery.ajax() - JSONP - Custom JSONP Callback", function() {
1278 window.jsonpResults = function(data) {
1279 ok( data.data, "JSON results returned (GET, custom callback function)" );
1280 window.jsonpResults = undefined;
1285 url: "data/jsonp.php",
1287 jsonpCallback: "jsonpResults"
1291 test("jQuery.ajax() - JSONP, Remote", function() {
1295 function plus(){ if ( ++count == 4 ) start(); }
1297 var base = window.location.href.replace(/[^\/]*$/, "");
1302 url: base + "data/jsonp.php",
1304 success: function(data){
1305 ok( data.data, "JSON results returned (GET, no callback)" );
1308 error: function(data){
1309 ok( false, "Ajax error JSON (GET, no callback)" );
1315 url: base + "data/jsonp.php?callback=?",
1317 success: function(data){
1318 ok( data.data, "JSON results returned (GET, url callback)" );
1321 error: function(data){
1322 ok( false, "Ajax error JSON (GET, url callback)" );
1328 url: base + "data/jsonp.php",
1331 success: function(data){
1332 ok( data.data, "JSON results returned (GET, data callback)" );
1335 error: function(data){
1336 ok( false, "Ajax error JSON (GET, data callback)" );
1342 url: base + "data/jsonp.php",
1345 success: function(data){
1346 ok( data.data, "JSON results returned (GET, data obj callback)" );
1349 error: function(data){
1350 ok( false, "Ajax error JSON (GET, data obj callback)" );
1356 test("jQuery.ajax() - script, Remote", function() {
1359 var base = window.location.href.replace(/[^\/]*$/, "");
1364 url: base + "data/test.js",
1366 success: function(data){
1367 ok( foobar, "Script results returned (GET, no callback)" );
1373 test("jQuery.ajax() - script, Remote with POST", function() {
1376 var base = window.location.href.replace(/[^\/]*$/, "");
1381 url: base + "data/test.js",
1384 success: function(data, status){
1385 ok( foobar, "Script results returned (POST, no callback)" );
1386 equals( status, "success", "Script results returned (POST, no callback)" );
1389 error: function(xhr) {
1390 ok( false, "ajax error, status code: " + xhr.status );
1396 test("jQuery.ajax() - script, Remote with scheme-less URL", function() {
1399 var base = window.location.href.replace(/[^\/]*$/, "");
1400 base = base.replace(/^.*?\/\//, "//");
1405 url: base + "data/test.js",
1407 success: function(data){
1408 ok( foobar, "Script results returned (GET, no callback)" );
1414 test("jQuery.ajax() - malformed JSON", function() {
1420 url: "data/badjson.js",
1422 success: function(){
1423 ok( false, "Success." );
1426 error: function(xhr, msg, detailedMsg) {
1427 equals( "parsererror", msg, "A parse error occurred." );
1428 ok( /^Invalid JSON/.test(detailedMsg), "Detailed parsererror message provided" );
1434 test("jQuery.ajax() - script by content-type", function() {
1440 url: "data/script.php",
1441 data: { header: "script" },
1442 success: function() {
1448 test("jQuery.ajax() - json by content-type", function() {
1454 url: "data/json.php",
1455 data: { header: "json", json: "array" },
1456 success: function( json ) {
1457 ok( json.length >= 2, "Check length");
1458 equals( json[0].name, 'John', 'Check JSON: first, name' );
1459 equals( json[0].age, 21, 'Check JSON: first, age' );
1460 equals( json[1].name, 'Peter', 'Check JSON: second, name' );
1461 equals( json[1].age, 25, 'Check JSON: second, age' );
1467 test("jQuery.ajax() - json by content-type disabled with options", function() {
1473 url: url("data/json.php"),
1474 data: { header: "json", json: "array" },
1478 success: function( text ) {
1479 equals( typeof text , "string" , "json wasn't auto-determined" );
1480 var json = this.dataConverters["text => json"]( text );
1481 ok( json.length >= 2, "Check length");
1482 equals( json[0].name, 'John', 'Check JSON: first, name' );
1483 equals( json[0].age, 21, 'Check JSON: first, age' );
1484 equals( json[1].name, 'Peter', 'Check JSON: second, name' );
1485 equals( json[1].age, 25, 'Check JSON: second, age' );
1491 test("jQuery.getJSON(String, Hash, Function) - JSON array", function() {
1494 jQuery.getJSON(url("data/json.php"), {json: "array"}, function(json) {
1495 ok( json.length >= 2, "Check length");
1496 equals( json[0].name, 'John', 'Check JSON: first, name' );
1497 equals( json[0].age, 21, 'Check JSON: first, age' );
1498 equals( json[1].name, 'Peter', 'Check JSON: second, name' );
1499 equals( json[1].age, 25, 'Check JSON: second, age' );
1504 test("jQuery.getJSON(String, Function) - JSON object", function() {
1507 jQuery.getJSON(url("data/json.php"), function(json) {
1508 if (json && json.data) {
1509 equals( json.data.lang, 'en', 'Check JSON: lang' );
1510 equals( json.data.length, 25, 'Check JSON: length' );
1516 test("jQuery.getJSON - Using Native JSON", function() {
1519 var old = window.JSON;
1521 parse: function(str){
1522 ok( true, "Verifying that parse method was run" );
1528 jQuery.getJSON(url("data/json.php"), function(json) {
1530 equals( json, true, "Verifying return value" );
1535 test("jQuery.getJSON(String, Function) - JSON object with absolute url to local content", function() {
1538 var base = window.location.href.replace(/[^\/]*$/, "");
1541 jQuery.getJSON(url(base + "data/json.php"), function(json) {
1542 equals( json.data.lang, 'en', 'Check JSON: lang' );
1543 equals( json.data.length, 25, 'Check JSON: length' );
1548 test("jQuery.post - data", function() {
1552 jQuery.post(url("data/name.php"), {xml: "5-2", length: 3}, function(xml){
1553 jQuery('math', xml).each(function() {
1554 equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
1555 equals( jQuery('result', this).text(), '3', 'Check for XML' );
1561 test("jQuery.post(String, Hash, Function) - simple with xml", function() {
1566 jQuery.post(url("data/name.php"), {xml: "5-2"}, function(xml){
1567 jQuery('math', xml).each(function() {
1568 equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
1569 equals( jQuery('result', this).text(), '3', 'Check for XML' );
1571 if ( ++done === 2 ) start();
1574 jQuery.post(url("data/name.php?xml=5-2"), {}, function(xml){
1575 jQuery('math', xml).each(function() {
1576 equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
1577 equals( jQuery('result', this).text(), '3', 'Check for XML' );
1579 if ( ++done === 2 ) start();
1583 test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
1588 jQuery.ajaxSetup({timeout: 1000});
1590 var pass = function() {
1592 if ( passed == 2 ) {
1593 ok( true, 'Check local and global callbacks after timeout' );
1594 jQuery('#main').unbind("ajaxError");
1599 var fail = function(a,b,c) {
1600 ok( false, 'Check for timeout failed ' + a + ' ' + b );
1604 jQuery('#main').ajaxError(pass);
1608 url: url("data/name.php?wait=5"),
1614 jQuery.ajaxSetup({timeout: 0});
1617 test("jQuery.ajaxSetup({timeout: Number}) with localtimeout", function() {
1619 jQuery.ajaxSetup({timeout: 50});
1624 url: url("data/name.php?wait=1"),
1626 ok( false, 'Check for local timeout failed' );
1629 success: function() {
1630 ok( true, 'Check for local timeout' );
1636 jQuery.ajaxSetup({timeout: 0});
1639 test("jQuery.ajax - simple get", function() {
1644 url: url("data/name.php?name=foo"),
1645 success: function(msg){
1646 equals( msg, 'bar', 'Check for GET' );
1652 test("jQuery.ajax - simple post", function() {
1657 url: url("data/name.php"),
1659 success: function(msg){
1660 equals( msg, 'pan', 'Check for POST' );
1666 test("ajaxSetup()", function() {
1670 url: url("data/name.php?name=foo"),
1671 success: function(msg){
1672 equals( msg, 'bar', 'Check for GET' );
1680 test("custom timeout does not set error message when timeout occurs, see #970", function() {
1683 url: "data/name.php?wait=1",
1685 error: function(request, status) {
1686 ok( status != null, "status shouldn't be null in error handler" );
1687 equals( "timeout", status );
1694 test("data option: evaluate function values (#2806)", function() {
1697 url: "data/echoQuery.php",
1703 success: function(result) {
1704 equals( result, "key=value" );
1710 test("data option: empty bodies for non-GET requests", function() {
1713 url: "data/echoData.php",
1716 success: function(result) {
1717 equals( result, "" );
1723 test("jQuery.ajax - If-Modified-Since support", function() {
1728 var url = "data/if_modified_since.php?ts=" + new Date();
1733 success: function(data, status) {
1734 equals(status, "success");
1739 success: function(data, status) {
1740 if ( data === "FAIL" ) {
1741 ok(true, "Opera is incapable of doing .setRequestHeader('If-Modified-Since').");
1742 ok(true, "Opera is incapable of doing .setRequestHeader('If-Modified-Since').");
1744 equals(status, "notmodified");
1745 ok(data == null, "response body should be empty")
1750 // Do this because opera simply refuses to implement 304 handling :(
1751 // A feature-driven way of detecting this would be appreciated
1752 // See: http://gist.github.com/599419
1753 ok(jQuery.browser.opera, "error");
1754 ok(jQuery.browser.opera, "error");
1760 equals(false, "error");
1761 // Do this because opera simply refuses to implement 304 handling :(
1762 // A feature-driven way of detecting this would be appreciated
1763 // See: http://gist.github.com/599419
1764 ok(jQuery.browser.opera, "error");
1770 test("jQuery.ajax - Etag support", function() {
1775 var url = "data/etag.php?ts=" + new Date();
1780 success: function(data, status) {
1781 equals(status, "success");
1786 success: function(data, status) {
1787 if ( data === "FAIL" ) {
1788 ok(true, "Opera is incapable of doing .setRequestHeader('If-None-Match').");
1789 ok(true, "Opera is incapable of doing .setRequestHeader('If-None-Match').");
1791 equals(status, "notmodified");
1792 ok(data == null, "response body should be empty")
1797 // Do this because opera simply refuses to implement 304 handling :(
1798 // A feature-driven way of detecting this would be appreciated
1799 // See: http://gist.github.com/599419
1800 ok(jQuery.browser.opera, "error");
1801 ok(jQuery.browser.opera, "error");
1807 // Do this because opera simply refuses to implement 304 handling :(
1808 // A feature-driven way of detecting this would be appreciated
1809 // See: http://gist.github.com/599419
1810 ok(jQuery.browser.opera, "error");
1816 test("jQuery ajax - headers", function() {
1820 jQuery.ajax(url("data/css.php?wait=1&id=headers"), {
1822 testKey: "testValue"
1824 beforeSend: function( xhr ) {
1825 equals( xhr.getRequestHeader("testKey") , "testValue" , "Headers properly set" );
1826 setTimeout( start , 13 );
1833 test("jQuery ajax - failing cross-domain", function() {
1842 url: 'http://somewebsitethatdoesnotexist.com',
1843 success: function(){ ok( false , "success" ); },
1844 error: function(xhr,_,e){ ok( true , "file not found: " + xhr.status + " => " + e ); },
1845 complete: function() { if ( ! --i ) start(); }
1849 url: 'http://www.google.com',
1850 success: function(){ ok( false , "success" ); },
1851 error: function(xhr,_,e){ ok( true , "access denied: " + xhr.status + " => " + e ); },
1852 complete: function() { if ( ! --i ) start(); }
1857 test("jQuery ajax - atom+xml", function() {
1862 url: url( 'data/atom+xml.php' ),
1863 success: function(){ ok( true , "success" ); },
1864 error: function(){ ok( false , "error" ); },
1865 complete: function() { start(); }
1870 test("jQuery.ajax - active counter", function() {
1871 ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active );
1874 test( "jQuery.ajax - Location object as url (#7531)", 1, function () {
1875 var success = false;
1877 var xhr = jQuery.ajax({ url: document.location });
1882 ok( success, "document.location did not generate exception" );