@@ -368,7 +368,7 @@ QUnit.module( "ajax", {
368368 } ;
369369 } ) ;
370370
371- ajaxTest ( "jQuery.ajax() - URL fragment component preservation" , 4 , function ( assert ) {
371+ ajaxTest ( "jQuery.ajax() - URL fragment component preservation" , 5 , function ( assert ) {
372372 return [
373373 {
374374 url : baseURL + "name.html#foo" ,
@@ -400,6 +400,25 @@ QUnit.module( "ajax", {
400400 } ,
401401 error : true
402402 } ,
403+ {
404+ url : baseURL + "name.html?abc#foo" ,
405+ data : [
406+ {
407+ name : "test" ,
408+ value : 123
409+ } ,
410+ {
411+ name : "devo" ,
412+ value : "hat"
413+ }
414+ ] ,
415+ beforeSend : function ( xhr , settings ) {
416+ assert . equal ( settings . url , baseURL + "name.html?abc&test=123&devo=hat#foo" ,
417+ "hash preserved for request with query component and array data." ) ;
418+ return false ;
419+ } ,
420+ error : true
421+ } ,
403422 {
404423 url : baseURL + "name.html?abc#brownies" ,
405424 data : {
@@ -1356,43 +1375,92 @@ QUnit.module( "ajax", {
13561375 ] ;
13571376 } ) ;
13581377
1359- ajaxTest ( "jQuery.ajax() - JSON by content-type" , 5 , function ( assert ) {
1360- return {
1361- url : baseURL + "mock.php?action=json" ,
1362- data : {
1363- "header" : "json" ,
1364- "array" : "1"
1378+ ajaxTest ( "jQuery.ajax() - JSON by content-type" , 10 , function ( assert ) {
1379+ return [
1380+ {
1381+ url : baseURL + "mock.php?action=json" ,
1382+ data : {
1383+ "header" : "json" ,
1384+ "array" : "1"
1385+ } ,
1386+ success : function ( json ) {
1387+ assert . ok ( json . length >= 2 , "Check length" ) ;
1388+ assert . strictEqual ( json [ 0 ] [ "name" ] , "John" , "Check JSON: first, name" ) ;
1389+ assert . strictEqual ( json [ 0 ] [ "age" ] , 21 , "Check JSON: first, age" ) ;
1390+ assert . strictEqual ( json [ 1 ] [ "name" ] , "Peter" , "Check JSON: second, name" ) ;
1391+ assert . strictEqual ( json [ 1 ] [ "age" ] , 25 , "Check JSON: second, age" ) ;
1392+ }
13651393 } ,
1366- success : function ( json ) {
1367- assert . ok ( json . length >= 2 , "Check length" ) ;
1368- assert . strictEqual ( json [ 0 ] [ "name" ] , "John" , "Check JSON: first, name" ) ;
1369- assert . strictEqual ( json [ 0 ] [ "age" ] , 21 , "Check JSON: first, age" ) ;
1370- assert . strictEqual ( json [ 1 ] [ "name" ] , "Peter" , "Check JSON: second, name" ) ;
1371- assert . strictEqual ( json [ 1 ] [ "age" ] , 25 , "Check JSON: second, age" ) ;
1394+ {
1395+ url : baseURL + "mock.php?action=json" ,
1396+ data : [
1397+ {
1398+ name : "header" ,
1399+ value : "json"
1400+ } ,
1401+ {
1402+ name : "array" ,
1403+ value : "1"
1404+ }
1405+ ] ,
1406+ success : function ( json ) {
1407+ assert . ok ( json . length >= 2 , "Check length" ) ;
1408+ assert . strictEqual ( json [ 0 ] [ "name" ] , "John" , "Check JSON: first, name" ) ;
1409+ assert . strictEqual ( json [ 0 ] [ "age" ] , 21 , "Check JSON: first, age" ) ;
1410+ assert . strictEqual ( json [ 1 ] [ "name" ] , "Peter" , "Check JSON: second, name" ) ;
1411+ assert . strictEqual ( json [ 1 ] [ "age" ] , 25 , "Check JSON: second, age" ) ;
1412+ }
13721413 }
1373- } ;
1414+ ] ;
13741415 } ) ;
13751416
1376- ajaxTest ( "jQuery.ajax() - JSON by content-type disabled with options" , 6 , function ( assert ) {
1377- return {
1378- url : url ( "mock.php?action=json" ) ,
1379- data : {
1380- "header" : "json" ,
1381- "array" : "1"
1382- } ,
1383- contents : {
1384- "json" : false
1417+ ajaxTest ( "jQuery.ajax() - JSON by content-type disabled with options" , 12 , function ( assert ) {
1418+ return [
1419+ {
1420+ url : url ( "mock.php?action=json" ) ,
1421+ data : {
1422+ "header" : "json" ,
1423+ "array" : "1"
1424+ } ,
1425+ contents : {
1426+ "json" : false
1427+ } ,
1428+ success : function ( text ) {
1429+ assert . strictEqual ( typeof text , "string" , "json wasn't auto-determined" ) ;
1430+ var json = JSON . parse ( text ) ;
1431+ assert . ok ( json . length >= 2 , "Check length" ) ;
1432+ assert . strictEqual ( json [ 0 ] [ "name" ] , "John" , "Check JSON: first, name" ) ;
1433+ assert . strictEqual ( json [ 0 ] [ "age" ] , 21 , "Check JSON: first, age" ) ;
1434+ assert . strictEqual ( json [ 1 ] [ "name" ] , "Peter" , "Check JSON: second, name" ) ;
1435+ assert . strictEqual ( json [ 1 ] [ "age" ] , 25 , "Check JSON: second, age" ) ;
1436+ }
13851437 } ,
1386- success : function ( text ) {
1387- assert . strictEqual ( typeof text , "string" , "json wasn't auto-determined" ) ;
1388- var json = JSON . parse ( text ) ;
1389- assert . ok ( json . length >= 2 , "Check length" ) ;
1390- assert . strictEqual ( json [ 0 ] [ "name" ] , "John" , "Check JSON: first, name" ) ;
1391- assert . strictEqual ( json [ 0 ] [ "age" ] , 21 , "Check JSON: first, age" ) ;
1392- assert . strictEqual ( json [ 1 ] [ "name" ] , "Peter" , "Check JSON: second, name" ) ;
1393- assert . strictEqual ( json [ 1 ] [ "age" ] , 25 , "Check JSON: second, age" ) ;
1438+ {
1439+ url : url ( "mock.php?action=json" ) ,
1440+ data : [
1441+ {
1442+ name : "header" ,
1443+ value : "json"
1444+ } ,
1445+ {
1446+ name : "array" ,
1447+ value : "1"
1448+ }
1449+ ] ,
1450+ contents : {
1451+ "json" : false
1452+ } ,
1453+ success : function ( text ) {
1454+ assert . strictEqual ( typeof text , "string" , "json wasn't auto-determined" ) ;
1455+ var json = JSON . parse ( text ) ;
1456+ assert . ok ( json . length >= 2 , "Check length" ) ;
1457+ assert . strictEqual ( json [ 0 ] [ "name" ] , "John" , "Check JSON: first, name" ) ;
1458+ assert . strictEqual ( json [ 0 ] [ "age" ] , 21 , "Check JSON: first, age" ) ;
1459+ assert . strictEqual ( json [ 1 ] [ "name" ] , "Peter" , "Check JSON: second, name" ) ;
1460+ assert . strictEqual ( json [ 1 ] [ "age" ] , 25 , "Check JSON: second, age" ) ;
1461+ }
13941462 }
1395- } ;
1463+ ] ;
13961464 } ) ;
13971465
13981466 ajaxTest ( "jQuery.ajax() - simple get" , 1 , function ( assert ) {
@@ -1440,18 +1508,36 @@ QUnit.module( "ajax", {
14401508 } ;
14411509 } ) ;
14421510
1443- ajaxTest ( "jQuery.ajax() - data - text/plain (gh-2658)" , 1 , function ( assert ) {
1444- return {
1445- url : "bogus.html" ,
1446- data : { devo : "A Beautiful World" } ,
1447- type : "post" ,
1448- contentType : "text/plain" ,
1449- beforeSend : function ( _ , s ) {
1450- assert . strictEqual ( s . data , "devo=A%20Beautiful%20World" , "data is %20-encoded" ) ;
1451- return false ;
1511+ ajaxTest ( "jQuery.ajax() - data - text/plain (gh-2658)" , 2 , function ( assert ) {
1512+ return [
1513+ {
1514+ url : "bogus.html" ,
1515+ data : { devo : "A Beautiful World" } ,
1516+ type : "post" ,
1517+ contentType : "text/plain" ,
1518+ beforeSend : function ( _ , s ) {
1519+ assert . strictEqual ( s . data , "devo=A%20Beautiful%20World" , "data is %20-encoded" ) ;
1520+ return false ;
1521+ } ,
1522+ error : true
14521523 } ,
1453- error : true
1454- } ;
1524+ {
1525+ url : "bogus.html" ,
1526+ data : [
1527+ {
1528+ name : "devo" ,
1529+ value : "A Beautiful World"
1530+ }
1531+ ] ,
1532+ type : "post" ,
1533+ contentType : "text/plain" ,
1534+ beforeSend : function ( _ , s ) {
1535+ assert . strictEqual ( s . data , "devo=A%20Beautiful%20World" , "data is %20-encoded" ) ;
1536+ return false ;
1537+ } ,
1538+ error : true
1539+ }
1540+ ] ;
14551541 } ) ;
14561542
14571543 ajaxTest ( "jQuery.ajax() - don't escape %20 with contentType override (gh-4119)" , 1 , function ( assert ) {
@@ -1500,34 +1586,82 @@ QUnit.module( "ajax", {
15001586 } ;
15011587 } ) ;
15021588
1503- ajaxTest ( "jQuery.ajax() - data - no processing POST" , 1 , function ( assert ) {
1504- return {
1505- url : "bogus.html" ,
1506- data : { devo : "A Beautiful World" } ,
1507- type : "post" ,
1508- contentType : "x-special-sauce" ,
1509- processData : false ,
1510- beforeSend : function ( _ , s ) {
1511- assert . deepEqual ( s . data , { devo : "A Beautiful World" } , "data is not processed" ) ;
1512- return false ;
1589+ ajaxTest ( "jQuery.ajax() - data - no processing POST" , 2 , function ( assert ) {
1590+ return [
1591+ {
1592+ url : "bogus.html" ,
1593+ data : { devo : "A Beautiful World" } ,
1594+ type : "post" ,
1595+ contentType : "x-special-sauce" ,
1596+ processData : false ,
1597+ beforeSend : function ( _ , s ) {
1598+ assert . deepEqual ( s . data , { devo : "A Beautiful World" } , "data is not processed" ) ;
1599+ return false ;
1600+ } ,
1601+ error : true
15131602 } ,
1514- error : true
1515- } ;
1603+ {
1604+ url : "bogus.html" ,
1605+ data : [
1606+ {
1607+ name : "devo" ,
1608+ value : "A Beautiful World"
1609+ }
1610+ ] ,
1611+ type : "post" ,
1612+ contentType : "x-special-sauce" ,
1613+ processData : false ,
1614+ beforeSend : function ( _ , s ) {
1615+ assert . deepEqual ( s . data , [
1616+ {
1617+ name : "devo" ,
1618+ value : "A Beautiful World"
1619+ }
1620+ ] , "data is not processed" ) ;
1621+ return false ;
1622+ } ,
1623+ error : true
1624+ }
1625+ ] ;
15161626 } ) ;
15171627
1518- ajaxTest ( "jQuery.ajax() - data - no processing GET" , 1 , function ( assert ) {
1519- return {
1520- url : "bogus.html" ,
1521- data : { devo : "A Beautiful World" } ,
1522- type : "get" ,
1523- contentType : "x-something-else" ,
1524- processData : false ,
1525- beforeSend : function ( _ , s ) {
1526- assert . deepEqual ( s . data , { devo : "A Beautiful World" } , "data is not processed" ) ;
1527- return false ;
1628+ ajaxTest ( "jQuery.ajax() - data - no processing GET" , 2 , function ( assert ) {
1629+ return [
1630+ {
1631+ url : "bogus.html" ,
1632+ data : { devo : "A Beautiful World" } ,
1633+ type : "get" ,
1634+ contentType : "x-something-else" ,
1635+ processData : false ,
1636+ beforeSend : function ( _ , s ) {
1637+ assert . deepEqual ( s . data , { devo : "A Beautiful World" } , "data is not processed" ) ;
1638+ return false ;
1639+ } ,
1640+ error : true
15281641 } ,
1529- error : true
1530- } ;
1642+ {
1643+ url : "bogus.html" ,
1644+ data : [
1645+ {
1646+ name : "devo" ,
1647+ value : "A Beautiful World"
1648+ }
1649+ ] ,
1650+ type : "get" ,
1651+ contentType : "x-something-else" ,
1652+ processData : false ,
1653+ beforeSend : function ( _ , s ) {
1654+ assert . deepEqual ( s . data , [
1655+ {
1656+ name : "devo" ,
1657+ value : "A Beautiful World"
1658+ }
1659+ ] , "data is not processed" ) ;
1660+ return false ;
1661+ } ,
1662+ error : true
1663+ }
1664+ ] ;
15311665 } ) ;
15321666
15331667 ajaxTest ( "jQuery.ajax() - data - process string with GET" , 2 , function ( assert ) {
0 commit comments