@@ -397,7 +397,7 @@ QUnit.module( "ajax", {
397397 } ;
398398 } ) ;
399399
400- ajaxTest ( "jQuery.ajax() - URL fragment component preservation" , 4 , function ( assert ) {
400+ ajaxTest ( "jQuery.ajax() - URL fragment component preservation" , 5 , function ( assert ) {
401401 return [
402402 {
403403 url : baseURL + "name.html#foo" ,
@@ -429,6 +429,25 @@ QUnit.module( "ajax", {
429429 } ,
430430 error : true
431431 } ,
432+ {
433+ url : baseURL + "name.html?abc#foo" ,
434+ data : [
435+ {
436+ name : "test" ,
437+ value : 123
438+ } ,
439+ {
440+ name : "devo" ,
441+ value : "hat"
442+ }
443+ ] ,
444+ beforeSend : function ( xhr , settings ) {
445+ assert . equal ( settings . url , baseURL + "name.html?abc&test=123&devo=hat#foo" ,
446+ "hash preserved for request with query component and array data." ) ;
447+ return false ;
448+ } ,
449+ error : true
450+ } ,
432451 {
433452 url : baseURL + "name.html?abc#brownies" ,
434453 data : {
@@ -1489,43 +1508,92 @@ QUnit.module( "ajax", {
14891508 } ;
14901509 } ) ;
14911510
1492- ajaxTest ( "jQuery.ajax() - JSON by content-type" , 5 , function ( assert ) {
1493- return {
1494- url : baseURL + "mock.php?action=json" ,
1495- data : {
1496- "header" : "json" ,
1497- "array" : "1"
1511+ ajaxTest ( "jQuery.ajax() - JSON by content-type" , 10 , function ( assert ) {
1512+ return [
1513+ {
1514+ url : baseURL + "mock.php?action=json" ,
1515+ data : {
1516+ "header" : "json" ,
1517+ "array" : "1"
1518+ } ,
1519+ success : function ( json ) {
1520+ assert . ok ( json . length >= 2 , "Check length" ) ;
1521+ assert . strictEqual ( json [ 0 ] [ "name" ] , "John" , "Check JSON: first, name" ) ;
1522+ assert . strictEqual ( json [ 0 ] [ "age" ] , 21 , "Check JSON: first, age" ) ;
1523+ assert . strictEqual ( json [ 1 ] [ "name" ] , "Peter" , "Check JSON: second, name" ) ;
1524+ assert . strictEqual ( json [ 1 ] [ "age" ] , 25 , "Check JSON: second, age" ) ;
1525+ }
14981526 } ,
1499- success : function ( json ) {
1500- assert . ok ( json . length >= 2 , "Check length" ) ;
1501- assert . strictEqual ( json [ 0 ] [ "name" ] , "John" , "Check JSON: first, name" ) ;
1502- assert . strictEqual ( json [ 0 ] [ "age" ] , 21 , "Check JSON: first, age" ) ;
1503- assert . strictEqual ( json [ 1 ] [ "name" ] , "Peter" , "Check JSON: second, name" ) ;
1504- assert . strictEqual ( json [ 1 ] [ "age" ] , 25 , "Check JSON: second, age" ) ;
1527+ {
1528+ url : baseURL + "mock.php?action=json" ,
1529+ data : [
1530+ {
1531+ name : "header" ,
1532+ value : "json"
1533+ } ,
1534+ {
1535+ name : "array" ,
1536+ value : "1"
1537+ }
1538+ ] ,
1539+ success : function ( json ) {
1540+ assert . ok ( json . length >= 2 , "Check length" ) ;
1541+ assert . strictEqual ( json [ 0 ] [ "name" ] , "John" , "Check JSON: first, name" ) ;
1542+ assert . strictEqual ( json [ 0 ] [ "age" ] , 21 , "Check JSON: first, age" ) ;
1543+ assert . strictEqual ( json [ 1 ] [ "name" ] , "Peter" , "Check JSON: second, name" ) ;
1544+ assert . strictEqual ( json [ 1 ] [ "age" ] , 25 , "Check JSON: second, age" ) ;
1545+ }
15051546 }
1506- } ;
1547+ ] ;
15071548 } ) ;
15081549
1509- ajaxTest ( "jQuery.ajax() - JSON by content-type disabled with options" , 6 , function ( assert ) {
1510- return {
1511- url : url ( "mock.php?action=json" ) ,
1512- data : {
1513- "header" : "json" ,
1514- "array" : "1"
1515- } ,
1516- contents : {
1517- "json" : false
1550+ ajaxTest ( "jQuery.ajax() - JSON by content-type disabled with options" , 12 , function ( assert ) {
1551+ return [
1552+ {
1553+ url : url ( "mock.php?action=json" ) ,
1554+ data : {
1555+ "header" : "json" ,
1556+ "array" : "1"
1557+ } ,
1558+ contents : {
1559+ "json" : false
1560+ } ,
1561+ success : function ( text ) {
1562+ assert . strictEqual ( typeof text , "string" , "json wasn't auto-determined" ) ;
1563+ var json = JSON . parse ( text ) ;
1564+ assert . ok ( json . length >= 2 , "Check length" ) ;
1565+ assert . strictEqual ( json [ 0 ] [ "name" ] , "John" , "Check JSON: first, name" ) ;
1566+ assert . strictEqual ( json [ 0 ] [ "age" ] , 21 , "Check JSON: first, age" ) ;
1567+ assert . strictEqual ( json [ 1 ] [ "name" ] , "Peter" , "Check JSON: second, name" ) ;
1568+ assert . strictEqual ( json [ 1 ] [ "age" ] , 25 , "Check JSON: second, age" ) ;
1569+ }
15181570 } ,
1519- success : function ( text ) {
1520- assert . strictEqual ( typeof text , "string" , "json wasn't auto-determined" ) ;
1521- var json = JSON . parse ( text ) ;
1522- assert . ok ( json . length >= 2 , "Check length" ) ;
1523- assert . strictEqual ( json [ 0 ] [ "name" ] , "John" , "Check JSON: first, name" ) ;
1524- assert . strictEqual ( json [ 0 ] [ "age" ] , 21 , "Check JSON: first, age" ) ;
1525- assert . strictEqual ( json [ 1 ] [ "name" ] , "Peter" , "Check JSON: second, name" ) ;
1526- assert . strictEqual ( json [ 1 ] [ "age" ] , 25 , "Check JSON: second, age" ) ;
1571+ {
1572+ url : url ( "mock.php?action=json" ) ,
1573+ data : [
1574+ {
1575+ name : "header" ,
1576+ value : "json"
1577+ } ,
1578+ {
1579+ name : "array" ,
1580+ value : "1"
1581+ }
1582+ ] ,
1583+ contents : {
1584+ "json" : false
1585+ } ,
1586+ success : function ( text ) {
1587+ assert . strictEqual ( typeof text , "string" , "json wasn't auto-determined" ) ;
1588+ var json = JSON . parse ( text ) ;
1589+ assert . ok ( json . length >= 2 , "Check length" ) ;
1590+ assert . strictEqual ( json [ 0 ] [ "name" ] , "John" , "Check JSON: first, name" ) ;
1591+ assert . strictEqual ( json [ 0 ] [ "age" ] , 21 , "Check JSON: first, age" ) ;
1592+ assert . strictEqual ( json [ 1 ] [ "name" ] , "Peter" , "Check JSON: second, name" ) ;
1593+ assert . strictEqual ( json [ 1 ] [ "age" ] , 25 , "Check JSON: second, age" ) ;
1594+ }
15271595 }
1528- } ;
1596+ ] ;
15291597 } ) ;
15301598
15311599 ajaxTest ( "jQuery.ajax() - simple get" , 1 , function ( assert ) {
@@ -1573,18 +1641,36 @@ QUnit.module( "ajax", {
15731641 } ;
15741642 } ) ;
15751643
1576- ajaxTest ( "jQuery.ajax() - data - text/plain (gh-2658)" , 1 , function ( assert ) {
1577- return {
1578- url : "bogus.html" ,
1579- data : { devo : "A Beautiful World" } ,
1580- type : "post" ,
1581- contentType : "text/plain" ,
1582- beforeSend : function ( _ , s ) {
1583- assert . strictEqual ( s . data , "devo=A%20Beautiful%20World" , "data is %20-encoded" ) ;
1584- return false ;
1644+ ajaxTest ( "jQuery.ajax() - data - text/plain (gh-2658)" , 2 , function ( assert ) {
1645+ return [
1646+ {
1647+ url : "bogus.html" ,
1648+ data : { devo : "A Beautiful World" } ,
1649+ type : "post" ,
1650+ contentType : "text/plain" ,
1651+ beforeSend : function ( _ , s ) {
1652+ assert . strictEqual ( s . data , "devo=A%20Beautiful%20World" , "data is %20-encoded" ) ;
1653+ return false ;
1654+ } ,
1655+ error : true
15851656 } ,
1586- error : true
1587- } ;
1657+ {
1658+ url : "bogus.html" ,
1659+ data : [
1660+ {
1661+ name : "devo" ,
1662+ value : "A Beautiful World"
1663+ }
1664+ ] ,
1665+ type : "post" ,
1666+ contentType : "text/plain" ,
1667+ beforeSend : function ( _ , s ) {
1668+ assert . strictEqual ( s . data , "devo=A%20Beautiful%20World" , "data is %20-encoded" ) ;
1669+ return false ;
1670+ } ,
1671+ error : true
1672+ }
1673+ ] ;
15881674 } ) ;
15891675
15901676 ajaxTest ( "jQuery.ajax() - don't escape %20 with contentType override (gh-4119)" , 1 , function ( assert ) {
@@ -1633,34 +1719,82 @@ QUnit.module( "ajax", {
16331719 } ;
16341720 } ) ;
16351721
1636- ajaxTest ( "jQuery.ajax() - data - no processing POST" , 1 , function ( assert ) {
1637- return {
1638- url : "bogus.html" ,
1639- data : { devo : "A Beautiful World" } ,
1640- type : "post" ,
1641- contentType : "x-special-sauce" ,
1642- processData : false ,
1643- beforeSend : function ( _ , s ) {
1644- assert . deepEqual ( s . data , { devo : "A Beautiful World" } , "data is not processed" ) ;
1645- return false ;
1722+ ajaxTest ( "jQuery.ajax() - data - no processing POST" , 2 , function ( assert ) {
1723+ return [
1724+ {
1725+ url : "bogus.html" ,
1726+ data : { devo : "A Beautiful World" } ,
1727+ type : "post" ,
1728+ contentType : "x-special-sauce" ,
1729+ processData : false ,
1730+ beforeSend : function ( _ , s ) {
1731+ assert . deepEqual ( s . data , { devo : "A Beautiful World" } , "data is not processed" ) ;
1732+ return false ;
1733+ } ,
1734+ error : true
16461735 } ,
1647- error : true
1648- } ;
1736+ {
1737+ url : "bogus.html" ,
1738+ data : [
1739+ {
1740+ name : "devo" ,
1741+ value : "A Beautiful World"
1742+ }
1743+ ] ,
1744+ type : "post" ,
1745+ contentType : "x-special-sauce" ,
1746+ processData : false ,
1747+ beforeSend : function ( _ , s ) {
1748+ assert . deepEqual ( s . data , [
1749+ {
1750+ name : "devo" ,
1751+ value : "A Beautiful World"
1752+ }
1753+ ] , "data is not processed" ) ;
1754+ return false ;
1755+ } ,
1756+ error : true
1757+ }
1758+ ] ;
16491759 } ) ;
16501760
1651- ajaxTest ( "jQuery.ajax() - data - no processing GET" , 1 , function ( assert ) {
1652- return {
1653- url : "bogus.html" ,
1654- data : { devo : "A Beautiful World" } ,
1655- type : "get" ,
1656- contentType : "x-something-else" ,
1657- processData : false ,
1658- beforeSend : function ( _ , s ) {
1659- assert . deepEqual ( s . data , { devo : "A Beautiful World" } , "data is not processed" ) ;
1660- return false ;
1761+ ajaxTest ( "jQuery.ajax() - data - no processing GET" , 2 , function ( assert ) {
1762+ return [
1763+ {
1764+ url : "bogus.html" ,
1765+ data : { devo : "A Beautiful World" } ,
1766+ type : "get" ,
1767+ contentType : "x-something-else" ,
1768+ processData : false ,
1769+ beforeSend : function ( _ , s ) {
1770+ assert . deepEqual ( s . data , { devo : "A Beautiful World" } , "data is not processed" ) ;
1771+ return false ;
1772+ } ,
1773+ error : true
16611774 } ,
1662- error : true
1663- } ;
1775+ {
1776+ url : "bogus.html" ,
1777+ data : [
1778+ {
1779+ name : "devo" ,
1780+ value : "A Beautiful World"
1781+ }
1782+ ] ,
1783+ type : "get" ,
1784+ contentType : "x-something-else" ,
1785+ processData : false ,
1786+ beforeSend : function ( _ , s ) {
1787+ assert . deepEqual ( s . data , [
1788+ {
1789+ name : "devo" ,
1790+ value : "A Beautiful World"
1791+ }
1792+ ] , "data is not processed" ) ;
1793+ return false ;
1794+ } ,
1795+ error : true
1796+ }
1797+ ] ;
16641798 } ) ;
16651799
16661800 ajaxTest ( "jQuery.ajax() - data - process string with GET" , 2 , function ( assert ) {
0 commit comments