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() {
287 var requestHeaders = {
289 "SometHing-elsE": "other value",
290 OthEr: "something else"
295 for( i in requestHeaders ) {
299 jQuery.ajax(url("data/headers.php?keys="+list.join( "_" ) ), {
300 headers: requestHeaders,
301 success: function( data , _ , xhr ) {
303 for ( i in requestHeaders ) {
304 tmp.push( i , ": " , requestHeaders[ i ] , "\n" );
306 tmp = tmp.join( "" );
308 equals( data , tmp , "Headers were sent" );
309 equals( xhr.getResponseHeader( "Sample-Header" ) , "Hello World" , "Sample header received" );
312 error: function(){ ok(false, "error"); }
317 test(".ajax() - hash", function() {
321 url: "data/name.html#foo",
322 beforeSend: function( xhr, settings ) {
323 equals(settings.url, "data/name.html", "Make sure that the URL is trimmed.");
329 url: "data/name.html?abc#foo",
330 beforeSend: function( xhr, settings ) {
331 equals(settings.url, "data/name.html?abc", "Make sure that the URL is trimmed.");
337 url: "data/name.html?abc#foo",
338 data: { "test": 123 },
339 beforeSend: function( xhr, settings ) {
340 equals(settings.url, "data/name.html?abc&test=123", "Make sure that the URL is trimmed.");
346 test(".ajax() - 304", function() {
351 url: url("data/notmodified.php"),
352 success: function(){ ok(true, "304 ok"); },
353 // Do this because opera simply refuses to implement 304 handling :(
354 // A feature-driven way of detecting this would be appreciated
355 // See: http://gist.github.com/599419
356 error: function(){ ok(jQuery.browser.opera, "304 not ok "); },
357 complete: function(xhr){ start(); }
361 test(".load()) - 404 error callbacks", function() {
365 jQuery('#foo').ajaxStart(function(){
366 ok( true, "ajaxStart" );
367 }).ajaxStop(function(){
368 ok( true, "ajaxStop" );
370 }).ajaxSend(function(){
371 ok( true, "ajaxSend" );
372 }).ajaxComplete(function(){
373 ok( true, "ajaxComplete" );
374 }).ajaxError(function(){
375 ok( true, "ajaxError" );
376 }).ajaxSuccess(function(){
377 ok( false, "ajaxSuccess" );
380 jQuery("<div/>").load("data/404.html", function(){
381 ok(true, "complete");
385 test("jQuery.ajax() - abort", function() {
389 jQuery('#foo').ajaxStart(function(){
390 ok( true, "ajaxStart" );
391 }).ajaxStop(function(){
392 ok( true, "ajaxStop" );
394 }).ajaxSend(function(){
395 ok( true, "ajaxSend" );
396 }).ajaxComplete(function(){
397 ok( true, "ajaxComplete" );
400 var xhr = jQuery.ajax({
401 url: url("data/name.php?wait=5"),
402 beforeSend: function(){ ok(true, "beforeSend"); },
403 complete: function(){ ok(true, "complete"); }
406 equals( xhr.readyState, 1, "XHR readyState indicates successful dispatch" );
409 equals( xhr.readyState, 0, "XHR readyState indicates successful abortion" );
412 test("jQuery.ajax() - readyState (success)", function() {
415 jQuery.ajaxSetup({ timeout: 0 });
421 setTimeout(function(){
423 url: url("data/name.html"),
424 beforeSend: function( xhr ) {
425 xhr.onreadystatechange = function() {
426 control += xhr.readyState;
429 complete: function(){
430 setTimeout( function() {
431 equals( control , "1234" , "onreadystatechange was properly called" );
439 test("jQuery.ajax() - readyState (abort)", function() {
442 jQuery.ajaxSetup({ timeout: 0 });
448 setTimeout(function(){
450 jQuery.ajaxSetup({ timeout: 500 });
453 url: url("data/name.php?wait=5"),
454 beforeSend: function( xhr ) {
455 xhr.onreadystatechange = function() {
456 control += xhr.readyState;
459 complete: function( xhr ){
460 setTimeout( function() {
461 equals( control , "14" , "onreadystatechange was properly called" );
462 equals( xhr.readyState, 0 , "readyState is 0" );
470 test("jQuery.xhr() - reuse", function() {
473 jQuery.ajaxSetup({ timeout: 0 });
479 setTimeout(function(){
480 jQuery('#foo').ajaxStart(function(){
481 ok( true, "ajaxStart" );
482 }).ajaxStop(function(){
483 ok( true, "ajaxStop" );
485 }).ajaxSend(function(){
487 ok( true, "ajaxSend (" + number +")" );
488 }).ajaxComplete(function(){
489 ok( true, "ajaxComplete (" + number +")" );
490 }).ajaxError(function(){
491 ok( false, "ajaxError (" + number +")" );
492 }).ajaxSuccess(function(){
493 ok( true, "ajaxSuccess (" + number +")" );
497 url: url("data/name.html"),
498 beforeSend: function(){ ok(true, "beforeSend (1)"); },
499 success: function( _1 , _2 , xhr ){
500 ok(true, "success (1)");
501 xhr.complete(function() {
502 ok(true, "complete (1bis)");
504 xhr.open( "GET", url("data/name.html") );
505 xhr.success( function(){ ok(true, "beforeSend (2)"); } )
507 success: function(){ ok(true, "success (2)"); },
508 error: function(){ ok(false, "error (2)"); },
509 complete: function(){ ok(true, "complete (2)"); }
512 error: function(){ ok(false, "error (1)"); },
513 complete: function(){ ok(true, "complete (1)"); }
518 test("jQuery.xhr() - early binding", function() {
521 jQuery.ajaxSetup({ timeout: 0 });
526 .success( function(){ ok(true, "success"); } )
527 .error( function(){ ok(false, "error"); } )
528 .complete( function(){ ok(true, "complete"); start(); } )
529 .open( "GET", url("data/name.html") )
533 test("jQuery.xhr() - get native implementation", function() {
535 var xhr = jQuery.xhr(true);
537 ok( xhr.readyState !== undefined , "implements XMLHttpRequest" );
538 ok( ! jQuery.isFunction( xhr.success ) , "is not jQuery's abstraction" );
542 test("Ajax events with context", function() {
546 var context = document.createElement("div");
549 equals( this, context, e.type );
552 function callback(msg){
554 equals( this, context, "context is preserved on callback " + msg );
558 function nocallback(msg){
560 equals( typeof this.url, "string", "context is settings on callback " + msg );
564 jQuery('#foo').add(context)
571 url: url("data/name.html"),
572 beforeSend: callback("beforeSend"),
573 success: callback("success"),
574 error: callback("error"),
576 callback("complete").call(this);
579 url: url("data/404.html"),
581 beforeSend: callback("beforeSend"),
582 error: callback("error"),
583 complete: function(){
584 callback("complete").call(this);
586 jQuery('#foo').add(context).unbind();
589 url: url("data/404.html"),
590 beforeSend: nocallback("beforeSend"),
591 error: nocallback("error"),
592 complete: function(){
593 nocallback("complete").call(this);
604 test("jQuery.ajax context modification", function() {
612 url: url("data/name.html"),
614 beforeSend: function(){
617 complete: function() {
622 equals( obj.test, "foo", "Make sure the original object is maintained." );
625 test("jQuery.ajax() - disabled globals", function() {
629 jQuery('#foo').ajaxStart(function(){
630 ok( false, "ajaxStart" );
631 }).ajaxStop(function(){
632 ok( false, "ajaxStop" );
633 }).ajaxSend(function(){
634 ok( false, "ajaxSend" );
635 }).ajaxComplete(function(){
636 ok( false, "ajaxComplete" );
637 }).ajaxError(function(){
638 ok( false, "ajaxError" );
639 }).ajaxSuccess(function(){
640 ok( false, "ajaxSuccess" );
645 url: url("data/name.html"),
646 beforeSend: function(){ ok(true, "beforeSend"); },
647 success: function(){ ok(true, "success"); },
648 error: function(){ ok(false, "error"); },
649 complete: function(){
650 ok(true, "complete");
651 setTimeout(function(){ start(); }, 13);
656 test("jQuery.xhr() - disabled globals through xhr.send(data , false)", function() {
660 jQuery('#foo').ajaxStart(function(){
661 ok( false, "ajaxStart" );
662 }).ajaxStop(function(){
663 ok( false, "ajaxStop" );
664 }).ajaxSend(function(){
665 ok( false, "ajaxSend" );
666 }).ajaxComplete(function(){
667 ok( false, "ajaxComplete" );
668 }).ajaxError(function(){
669 ok( false, "ajaxError" );
670 }).ajaxSuccess(function(){
671 ok( false, "ajaxSuccess" );
675 .success(function(){ ok(true, "success"); })
676 .error(function(){ ok(false, "error"); })
677 .complete(function(){
678 ok(true, "complete");
679 setTimeout(function(){ start(); }, 13);
681 .open("GET", url("data/name.html")).send(undefined, false);
684 test("jQuery.ajax - xml: non-namespace elements inside namespaced elements", function() {
688 url: url("data/with_fries.xml"),
690 success: function(resp) {
691 equals( jQuery("properties", resp).length, 1, 'properties in responseXML' );
692 equals( jQuery("jsconf", resp).length, 1, 'jsconf in responseXML' );
693 equals( jQuery("thing", resp).length, 2, 'things in responseXML' );
699 test("jQuery.ajax - xml: non-namespace elements inside namespaced elements (over JSONP)", function() {
703 url: url("data/with_fries_over_jsonp.php"),
704 dataType: "jsonp xml",
705 success: function(resp) {
706 equals( jQuery("properties", resp).length, 1, 'properties in responseXML' );
707 equals( jQuery("jsconf", resp).length, 1, 'jsconf in responseXML' );
708 equals( jQuery("thing", resp).length, 2, 'things in responseXML' );
711 error: function(_1,_2,error) {
718 test("jQuery.ajax - HEAD requests", function() {
723 url: url("data/name.html"),
725 success: function(data, status, xhr){
726 var h = xhr.getAllResponseHeaders();
727 ok( /Date/i.test(h), 'No Date in HEAD response' );
730 url: url("data/name.html"),
731 data: { whip_it: "good" },
733 success: function(data, status, xhr){
734 var h = xhr.getAllResponseHeaders();
735 ok( /Date/i.test(h), 'No Date in HEAD response with data' );
744 test("jQuery.ajax - beforeSend", function() {
750 jQuery.ajaxSetup({ timeout: 0 });
753 url: url("data/name.html"),
754 beforeSend: function(xml) {
757 success: function(data) {
758 ok( check, "check beforeSend was executed" );
764 test("jQuery.ajax - beforeSend, cancel request (#2688)", function() {
766 var request = jQuery.ajax({
767 url: url("data/name.html"),
768 beforeSend: function() {
769 ok( true, "beforeSend got called, canceling" );
772 success: function() {
773 ok( false, "request didn't get canceled" );
775 complete: function() {
776 ok( false, "request didn't get canceled" );
779 ok( false, "request didn't get canceled" );
782 ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" );
785 test("jQuery.ajax - beforeSend, cancel request manually", function() {
787 var request = jQuery.ajax({
788 url: url("data/name.html"),
789 beforeSend: function(xhr) {
790 ok( true, "beforeSend got called, canceling" );
793 success: function() {
794 ok( false, "request didn't get canceled" );
796 complete: function() {
797 ok( false, "request didn't get canceled" );
800 ok( false, "request didn't get canceled" );
803 ok( request === false, "canceled request must return false instead of XMLHttpRequest instance" );
806 window.foobar = null;
807 window.testFoo = undefined;
809 test("jQuery.ajax - dataType html", function() {
813 var verifyEvaluation = function() {
814 equals( testFoo, "foo", 'Check if script was evaluated for datatype html' );
815 equals( foobar, "bar", 'Check if script src was evaluated for datatype html' );
822 url: url("data/test.html"),
823 success: function(data) {
824 jQuery("#ap").html(data);
825 ok( data.match(/^html text/), 'Check content for datatype html' );
826 setTimeout(verifyEvaluation, 600);
831 test("serialize()", function() {
834 // Add html5 elements only for serialize because selector can't yet find them on non-html5 browsers
835 jQuery("#search").after(
836 '<input type="email" id="html5email" name="email" value="dave@jquery.com" />'+
837 '<input type="number" id="html5number" name="number" value="43" />'
840 equals( jQuery('#form').serialize(),
841 "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",
842 'Check form serialization as query string');
844 equals( jQuery('#form :input').serialize(),
845 "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",
846 'Check input serialization as query string');
848 equals( jQuery('#testForm').serialize(),
849 'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
850 'Check form serialization as query string');
852 equals( jQuery('#testForm :input').serialize(),
853 'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
854 'Check input serialization as query string');
856 equals( jQuery('#form, #testForm').serialize(),
857 "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=",
858 'Multiple form serialization as query string');
860 /* Temporarily disabled. Opera 10 has problems with form serialization.
861 equals( jQuery('#form, #testForm :input').serialize(),
862 "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=",
863 'Mixed form/input serialization as query string');
865 jQuery("#html5email, #html5number").remove();
868 test("jQuery.param()", function() {
871 equals( !jQuery.ajaxSettings.traditional, true, "traditional flag, falsy by default" );
873 var params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
874 equals( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
876 params = {someName: [1, 2, 3], regularThing: "blah" };
877 equals( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" );
879 params = {foo: ['a', 'b', 'c']};
880 equals( jQuery.param(params), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" );
882 params = {foo: ["baz", 42, "All your base are belong to us"] };
883 equals( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
885 params = {foo: { bar: 'baz', beep: 42, quux: 'All your base are belong to us' } };
886 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" );
888 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?" };
889 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" );
891 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 ] };
892 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" );
894 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?" };
895 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" );
897 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." );
899 // Make sure empty arrays and objects are handled #6481
900 equals( jQuery.param({"foo": {"bar": []} }), "foo%5Bbar%5D=", "Empty array param" );
901 equals( jQuery.param({"foo": {"bar": [], foo: 1} }), "foo%5Bbar%5D=&foo%5Bfoo%5D=1", "Empty array param" );
902 equals( jQuery.param({"foo": {"bar": {}} }), "foo%5Bbar%5D=", "Empty object param" );
904 jQuery.ajaxSetup({ traditional: true });
906 var params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
907 equals( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
909 params = {someName: [1, 2, 3], regularThing: "blah" };
910 equals( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" );
912 params = {foo: ['a', 'b', 'c']};
913 equals( jQuery.param(params), "foo=a&foo=b&foo=c", "with array of strings" );
915 params = {"foo[]":["baz", 42, "All your base are belong to us"]};
916 equals( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
918 params = {"foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us"};
919 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" );
921 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?" };
922 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" );
924 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 ] };
925 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)" );
927 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?" };
928 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" );
930 params = { param1: null };
931 equals( jQuery.param(params,false), "param1=null", "Make sure that null params aren't traversed." );
934 test("synchronous request", function() {
936 ok( /^{ "data"/.test( jQuery.ajax({url: url("data/json_obj.js"), dataType: "text", async: false}).responseText ), "check returned text" );
939 test("synchronous request with callbacks", function() {
942 jQuery.ajax({url: url("data/json_obj.js"), async: false, dataType: "text", success: function(data) { ok(true, "sucess callback executed"); result = data; } });
943 ok( /^{ "data"/.test( result ), "check returned text" );
946 test("pass-through request object", function() {
950 var target = "data/name.html";
951 var successCount = 0;
954 var success = function() {
957 jQuery("#foo").ajaxError(function (e, xml, s, ex) {
959 errorEx += ": " + xml.status;
961 jQuery("#foo").one('ajaxStop', function () {
962 equals(successCount, 5, "Check all ajax calls successful");
963 equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")");
964 jQuery("#foo").unbind('ajaxError');
969 ok( jQuery.get(url(target), success), "get" );
970 ok( jQuery.post(url(target), success), "post" );
971 ok( jQuery.getScript(url("data/test.js"), success), "script" );
972 ok( jQuery.getJSON(url("data/json_obj.js"), success), "json" );
973 ok( jQuery.ajax({url: url(target), success: success}), "generic" );
976 test("ajax cache", function () {
983 jQuery("#firstp").bind("ajaxSuccess", function (e, xml, s) {
984 var re = /_=(.*?)(&|$)/g;
986 for (var i = 0; i < 6; i++) {
987 var ret = re.exec(s.url);
993 equals(i, 1, "Test to make sure only one 'no-cache' parameter is there");
994 ok(oldOne != "tobereplaced555", "Test to be sure parameter (if it was there) was replaced");
999 ok( jQuery.ajax({url: "data/text.php", cache:false}), "test with no parameters" );
1000 ok( jQuery.ajax({url: "data/text.php?pizza=true", cache:false}), "test with 1 parameter" );
1001 ok( jQuery.ajax({url: "data/text.php?_=tobereplaced555", cache:false}), "test with _= parameter" );
1002 ok( jQuery.ajax({url: "data/text.php?pizza=true&_=tobereplaced555", cache:false}), "test with 1 parameter plus _= one" );
1003 ok( jQuery.ajax({url: "data/text.php?_=tobereplaced555&tv=false", cache:false}), "test with 1 parameter plus _= one before it" );
1004 ok( jQuery.ajax({url: "data/text.php?name=David&_=tobereplaced555&washere=true", cache:false}), "test with 2 parameters surrounding _= one" );
1009 * The assertions expect that the passed-in object will be modified,
1010 * which shouldn't be the case. Fixes #5439.
1011 test("global ajaxSettings", function() {
1014 var tmp = jQuery.extend({}, jQuery.ajaxSettings);
1015 var orig = { url: "data/with_fries.xml" };
1018 jQuery.ajaxSetup({ data: {foo: 'bar', bar: 'BAR'} });
1020 t = jQuery.extend({}, orig);
1023 ok( t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending {}" );
1025 t = jQuery.extend({}, orig);
1026 t.data = { zoo: 'a', ping: 'b' };
1028 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' }" );
1030 jQuery.ajaxSettings = tmp;
1034 test("load(String)", function() {
1036 stop(); // check if load can be called with only url
1037 jQuery('#first').load("data/name.html", start);
1040 test("load('url selector')", function() {
1042 stop(); // check if load can be called with only url
1043 jQuery('#first').load("data/test3.html div.user", function(){
1044 equals( jQuery(this).children("div").length, 2, "Verify that specific elements were injected" );
1049 test("load(String, Function) with ajaxSetup on dataType json, see #2046", function() {
1052 jQuery.ajaxSetup({ dataType: "json" });
1053 jQuery("#first").ajaxComplete(function (e, xml, s) {
1054 equals( s.dataType, "html", "Verify the load() dataType was html" );
1055 jQuery("#first").unbind("ajaxComplete");
1056 jQuery.ajaxSetup({ dataType: "" });
1059 jQuery('#first').load("data/test3.html");
1062 test("load(String, Function) - simple: inject text into DOM", function() {
1065 jQuery('#first').load(url("data/name.html"), function() {
1066 ok( /^ERROR/.test(jQuery('#first').text()), 'Check if content was injected into the DOM' );
1071 test("load(String, Function) - check scripts", function() {
1075 var verifyEvaluation = function() {
1076 equals( foobar, "bar", 'Check if script src was evaluated after load' );
1077 equals( jQuery('#ap').html(), 'bar', 'Check if script evaluation has modified DOM');
1081 jQuery('#first').load(url('data/test.html'), function() {
1082 ok( jQuery('#first').html().match(/^html text/), 'Check content after loading html' );
1083 equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
1084 equals( testFoo, "foo", 'Check if script was evaluated after load' );
1085 setTimeout(verifyEvaluation, 600);
1089 test("load(String, Function) - check file with only a script tag", function() {
1093 jQuery('#first').load(url('data/test2.html'), function() {
1094 equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
1095 equals( testFoo, "foo", 'Check if script was evaluated after load' );
1101 test("load(String, Object, Function)", function() {
1105 jQuery('<div />').load(url('data/params_html.php'), { foo:3, bar:'ok' }, function() {
1106 var $post = jQuery(this).find('#post');
1107 equals( $post.find('#foo').text(), '3', 'Check if a hash of data is passed correctly');
1108 equals( $post.find('#bar').text(), 'ok', 'Check if a hash of data is passed correctly');
1113 test("load(String, String, Function)", function() {
1117 jQuery('<div />').load(url('data/params_html.php'), 'foo=3&bar=ok', function() {
1118 var $get = jQuery(this).find('#get');
1119 equals( $get.find('#foo').text(), '3', 'Check if a string of data is passed correctly');
1120 equals( $get.find('#bar').text(), 'ok', 'Check if a of data is passed correctly');
1125 test("jQuery.get(String, Hash, Function) - parse xml and use text() on nodes", function() {
1128 jQuery.get(url('data/dashboard.xml'), function(xml) {
1130 jQuery('tab', xml).each(function() {
1131 content.push(jQuery(this).text());
1133 equals( content[0], 'blabla', 'Check first tab');
1134 equals( content[1], 'blublu', 'Check second tab');
1139 test("jQuery.getScript(String, Function) - with callback", function() {
1142 jQuery.getScript(url("data/test.js"), function() {
1143 equals( foobar, "bar", 'Check if script was evaluated' );
1144 setTimeout(start, 100);
1148 test("jQuery.getScript(String, Function) - no callback", function() {
1151 jQuery.getScript(url("data/test.js"), function(){
1156 test("jQuery.ajax() - JSONP, Local", function() {
1160 function plus(){ if ( ++count == 9 ) start(); }
1165 url: "data/jsonp.php",
1167 success: function(data){
1168 ok( data.data, "JSON results returned (GET, no callback)" );
1171 error: function(data){
1172 ok( false, "Ajax error JSON (GET, no callback)" );
1178 url: "data/jsonp.php?callback=?",
1180 success: function(data){
1181 ok( data.data, "JSON results returned (GET, url callback)" );
1184 error: function(data){
1185 ok( false, "Ajax error JSON (GET, url callback)" );
1191 url: "data/jsonp.php",
1194 success: function(data){
1195 ok( data.data, "JSON results returned (GET, data callback)" );
1198 error: function(data){
1199 ok( false, "Ajax error JSON (GET, data callback)" );
1205 url: "data/jsonp.php",
1208 success: function(data){
1209 ok( data.data, "JSON results returned (GET, data obj callback)" );
1212 error: function(data){
1213 ok( false, "Ajax error JSON (GET, data obj callback)" );
1219 url: "data/jsonp.php",
1221 jsonpCallback: "jsonpResults",
1222 success: function(data){
1223 ok( data.data, "JSON results returned (GET, custom callback name)" );
1226 error: function(data){
1227 ok( false, "Ajax error JSON (GET, custom callback name)" );
1234 url: "data/jsonp.php",
1236 success: function(data){
1237 ok( data.data, "JSON results returned (POST, no callback)" );
1240 error: function(data){
1241 ok( false, "Ajax error JSON (GET, data obj callback)" );
1248 url: "data/jsonp.php",
1251 success: function(data){
1252 ok( data.data, "JSON results returned (POST, data callback)" );
1255 error: function(data){
1256 ok( false, "Ajax error JSON (POST, data callback)" );
1263 url: "data/jsonp.php",
1266 success: function(data){
1267 ok( data.data, "JSON results returned (POST, data obj callback)" );
1270 error: function(data){
1271 ok( false, "Ajax error JSON (POST, data obj callback)" );
1278 url: "data/jsonp.php",
1280 beforeSend: function(){
1281 strictEqual( this.cache, false, "cache must be false on JSON request" );
1288 test("jQuery.ajax() - JSONP - Custom JSONP Callback", function() {
1292 window.jsonpResults = function(data) {
1293 ok( data.data, "JSON results returned (GET, custom callback function)" );
1294 window.jsonpResults = undefined;
1299 url: "data/jsonp.php",
1301 jsonpCallback: "jsonpResults"
1305 test("jQuery.ajax() - JSONP, Remote", function() {
1309 function plus(){ if ( ++count == 4 ) start(); }
1311 var base = window.location.href.replace(/[^\/]*$/, "");
1316 url: base + "data/jsonp.php",
1318 success: function(data){
1319 ok( data.data, "JSON results returned (GET, no callback)" );
1322 error: function(data){
1323 ok( false, "Ajax error JSON (GET, no callback)" );
1329 url: base + "data/jsonp.php?callback=?",
1331 success: function(data){
1332 ok( data.data, "JSON results returned (GET, url callback)" );
1335 error: function(data){
1336 ok( false, "Ajax error JSON (GET, url callback)" );
1342 url: base + "data/jsonp.php",
1345 success: function(data){
1346 ok( data.data, "JSON results returned (GET, data callback)" );
1349 error: function(data){
1350 ok( false, "Ajax error JSON (GET, data callback)" );
1356 url: base + "data/jsonp.php",
1359 success: function(data){
1360 ok( data.data, "JSON results returned (GET, data obj callback)" );
1363 error: function(data){
1364 ok( false, "Ajax error JSON (GET, data obj callback)" );
1370 test("jQuery.ajax() - script, Remote", function() {
1373 var base = window.location.href.replace(/[^\/]*$/, "");
1378 url: base + "data/test.js",
1380 success: function(data){
1381 ok( foobar, "Script results returned (GET, no callback)" );
1387 test("jQuery.ajax() - script, Remote with POST", function() {
1390 var base = window.location.href.replace(/[^\/]*$/, "");
1395 url: base + "data/test.js",
1398 success: function(data, status){
1399 ok( foobar, "Script results returned (POST, no callback)" );
1400 equals( status, "success", "Script results returned (POST, no callback)" );
1403 error: function(xhr) {
1404 ok( false, "ajax error, status code: " + xhr.status );
1410 test("jQuery.ajax() - script, Remote with scheme-less URL", function() {
1413 var base = window.location.href.replace(/[^\/]*$/, "");
1414 base = base.replace(/^.*?\/\//, "//");
1419 url: base + "data/test.js",
1421 success: function(data){
1422 ok( foobar, "Script results returned (GET, no callback)" );
1428 test("jQuery.ajax() - malformed JSON", function() {
1434 url: "data/badjson.js",
1436 success: function(){
1437 ok( false, "Success." );
1440 error: function(xhr, msg, detailedMsg) {
1441 equals( "parsererror", msg, "A parse error occurred." );
1442 ok( /^Invalid JSON/.test(detailedMsg), "Detailed parsererror message provided" );
1448 test("jQuery.ajax() - script by content-type", function() {
1454 url: "data/script.php",
1455 data: { header: "script" },
1456 success: function() {
1462 test("jQuery.ajax() - json by content-type", function() {
1468 url: "data/json.php",
1469 data: { header: "json", json: "array" },
1470 success: function( json ) {
1471 ok( json.length >= 2, "Check length");
1472 equals( json[0].name, 'John', 'Check JSON: first, name' );
1473 equals( json[0].age, 21, 'Check JSON: first, age' );
1474 equals( json[1].name, 'Peter', 'Check JSON: second, name' );
1475 equals( json[1].age, 25, 'Check JSON: second, age' );
1481 test("jQuery.ajax() - json by content-type disabled with options", function() {
1487 url: url("data/json.php"),
1488 data: { header: "json", json: "array" },
1492 success: function( text ) {
1493 equals( typeof text , "string" , "json wasn't auto-determined" );
1494 var json = this.dataConverters["text json"]( text );
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' );
1505 test("jQuery.getJSON(String, Hash, Function) - JSON array", function() {
1508 jQuery.getJSON(url("data/json.php"), {json: "array"}, function(json) {
1509 ok( json.length >= 2, "Check length");
1510 equals( json[0].name, 'John', 'Check JSON: first, name' );
1511 equals( json[0].age, 21, 'Check JSON: first, age' );
1512 equals( json[1].name, 'Peter', 'Check JSON: second, name' );
1513 equals( json[1].age, 25, 'Check JSON: second, age' );
1518 test("jQuery.getJSON(String, Function) - JSON object", function() {
1521 jQuery.getJSON(url("data/json.php"), function(json) {
1522 if (json && json.data) {
1523 equals( json.data.lang, 'en', 'Check JSON: lang' );
1524 equals( json.data.length, 25, 'Check JSON: length' );
1530 test("jQuery.getJSON - Using Native JSON", function() {
1533 var old = window.JSON;
1535 parse: function(str){
1536 ok( true, "Verifying that parse method was run" );
1542 jQuery.getJSON(url("data/json.php"), function(json) {
1544 equals( json, true, "Verifying return value" );
1549 test("jQuery.getJSON(String, Function) - JSON object with absolute url to local content", function() {
1552 var base = window.location.href.replace(/[^\/]*$/, "");
1555 jQuery.getJSON(url(base + "data/json.php"), function(json) {
1556 equals( json.data.lang, 'en', 'Check JSON: lang' );
1557 equals( json.data.length, 25, 'Check JSON: length' );
1562 test("jQuery.post - data", function() {
1566 jQuery.post(url("data/name.php"), {xml: "5-2", length: 3}, 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' );
1575 test("jQuery.post(String, Hash, Function) - simple with xml", function() {
1580 jQuery.post(url("data/name.php"), {xml: "5-2"}, function(xml){
1581 jQuery('math', xml).each(function() {
1582 equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
1583 equals( jQuery('result', this).text(), '3', 'Check for XML' );
1585 if ( ++done === 2 ) start();
1588 jQuery.post(url("data/name.php?xml=5-2"), {}, function(xml){
1589 jQuery('math', xml).each(function() {
1590 equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
1591 equals( jQuery('result', this).text(), '3', 'Check for XML' );
1593 if ( ++done === 2 ) start();
1597 test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
1602 jQuery.ajaxSetup({timeout: 1000});
1604 var pass = function() {
1606 if ( passed == 2 ) {
1607 ok( true, 'Check local and global callbacks after timeout' );
1608 jQuery('#main').unbind("ajaxError");
1613 var fail = function(a,b,c) {
1614 ok( false, 'Check for timeout failed ' + a + ' ' + b );
1618 jQuery('#main').ajaxError(pass);
1622 url: url("data/name.php?wait=5"),
1628 jQuery.ajaxSetup({timeout: 0});
1631 test("jQuery.ajaxSetup({timeout: Number}) with localtimeout", function() {
1633 jQuery.ajaxSetup({timeout: 50});
1638 url: url("data/name.php?wait=1"),
1640 ok( false, 'Check for local timeout failed' );
1643 success: function() {
1644 ok( true, 'Check for local timeout' );
1650 jQuery.ajaxSetup({timeout: 0});
1653 test("jQuery.ajax - simple get", function() {
1658 url: url("data/name.php?name=foo"),
1659 success: function(msg){
1660 equals( msg, 'bar', 'Check for GET' );
1666 test("jQuery.ajax - simple post", function() {
1671 url: url("data/name.php"),
1673 success: function(msg){
1674 equals( msg, 'pan', 'Check for POST' );
1680 test("ajaxSetup()", function() {
1684 url: url("data/name.php?name=foo"),
1685 success: function(msg){
1686 equals( msg, 'bar', 'Check for GET' );
1694 test("custom timeout does not set error message when timeout occurs, see #970", function() {
1697 url: "data/name.php?wait=1",
1699 error: function(request, status) {
1700 ok( status != null, "status shouldn't be null in error handler" );
1701 equals( "timeout", status );
1708 test("data option: evaluate function values (#2806)", function() {
1711 url: "data/echoQuery.php",
1717 success: function(result) {
1718 equals( result, "key=value" );
1724 test("data option: empty bodies for non-GET requests", function() {
1727 url: "data/echoData.php",
1730 success: function(result) {
1731 equals( result, "" );
1737 test("jQuery.ajax - If-Modified-Since support", function() {
1742 var url = "data/if_modified_since.php?ts=" + new Date();
1747 success: function(data, status) {
1748 equals(status, "success");
1753 success: function(data, status) {
1754 if ( data === "FAIL" ) {
1755 ok(true, "Opera is incapable of doing .setRequestHeader('If-Modified-Since').");
1756 ok(true, "Opera is incapable of doing .setRequestHeader('If-Modified-Since').");
1758 equals(status, "notmodified");
1759 ok(data == null, "response body should be empty")
1764 // Do this because opera simply refuses to implement 304 handling :(
1765 // A feature-driven way of detecting this would be appreciated
1766 // See: http://gist.github.com/599419
1767 ok(jQuery.browser.opera, "error");
1768 ok(jQuery.browser.opera, "error");
1774 equals(false, "error");
1775 // Do this because opera simply refuses to implement 304 handling :(
1776 // A feature-driven way of detecting this would be appreciated
1777 // See: http://gist.github.com/599419
1778 ok(jQuery.browser.opera, "error");
1784 test("jQuery.ajax - Etag support", function() {
1789 var url = "data/etag.php?ts=" + new Date();
1794 success: function(data, status) {
1795 equals(status, "success");
1800 success: function(data, status) {
1801 if ( data === "FAIL" ) {
1802 ok(true, "Opera is incapable of doing .setRequestHeader('If-None-Match').");
1803 ok(true, "Opera is incapable of doing .setRequestHeader('If-None-Match').");
1805 equals(status, "notmodified");
1806 ok(data == null, "response body should be empty")
1811 // Do this because opera simply refuses to implement 304 handling :(
1812 // A feature-driven way of detecting this would be appreciated
1813 // See: http://gist.github.com/599419
1814 ok(jQuery.browser.opera, "error");
1815 ok(jQuery.browser.opera, "error");
1821 // Do this because opera simply refuses to implement 304 handling :(
1822 // A feature-driven way of detecting this would be appreciated
1823 // See: http://gist.github.com/599419
1824 ok(jQuery.browser.opera, "error");
1830 test("jQuery ajax - failing cross-domain", function() {
1839 url: 'http://somewebsitethatdoesnotexist.com',
1840 success: function(){ ok( false , "success" ); },
1841 error: function(xhr,_,e){ ok( true , "file not found: " + xhr.status + " => " + e ); },
1842 complete: function() { if ( ! --i ) start(); }
1846 url: 'http://www.google.com',
1847 success: function(){ ok( false , "success" ); },
1848 error: function(xhr,_,e){ ok( true , "access denied: " + xhr.status + " => " + e ); },
1849 complete: function() { if ( ! --i ) start(); }
1854 test("jQuery ajax - atom+xml", function() {
1859 url: url( 'data/atom+xml.php' ),
1860 success: function(){ ok( true , "success" ); },
1861 error: function(){ ok( false , "error" ); },
1862 complete: function() { start(); }
1867 test("jQuery.ajax - active counter", function() {
1868 ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active );
1871 test( "jQuery.ajax - Location object as url (#7531)", 1, function () {
1872 var success = false;
1874 var xhr = jQuery.ajax({ url: window.location });
1879 ok( success, "document.location did not generate exception" );