diff options
author | jaubourg <j@ubourg.net> | 2011-02-11 07:02:11 +0100 |
---|---|---|
committer | jaubourg <j@ubourg.net> | 2011-02-11 07:02:11 +0100 |
commit | 3a1d7a3c7c5349021f6dae979ab9b8609ae8f105 (patch) | |
tree | ca4f012acca5defe06051ce904ebb9bf8739cb9f /test/localfile.html | |
parent | 43a41ba7ecef732b48dcfc930fa9df8835fc4944 (diff) | |
download | jquery-3a1d7a3c7c5349021f6dae979ab9b8609ae8f105.tar.gz jquery-3a1d7a3c7c5349021f6dae979ab9b8609ae8f105.zip |
Simplifies status normalization in xhr transport. Local file test modified for clarity.
Diffstat (limited to 'test/localfile.html')
-rw-r--r-- | test/localfile.html | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/test/localfile.html b/test/localfile.html index c27e946e8..96e0f982c 100644 --- a/test/localfile.html +++ b/test/localfile.html @@ -27,20 +27,25 @@ .success { color: green; } </style> </head> - <body> <h1>jQuery Local File Test</h1> + <h2> + Introduction + </h2> <ul> <li> Access this file using the "file:" protocol, </li> <li> - two "OK" strings must appear below, + two green "OK" strings must appear below, </li> <li> - Opera will fail at detecting errors, it's a known issue. + Empty local files will issue errors, it's a known limitation. </li> </ul> + <h2> + Results + </h2> <ul> <li> Success: @@ -53,26 +58,35 @@ </span> </li> </ul> + <h2> + Logs: + </h2> + <ul id="log"> + </ul> <script> + var logUL = jQuery( "#log" ); + function doLog( message, args ) { + jQuery( "<li />").appendTo( logUL ).text( message + ': "' + Array.prototype.join.call( args, '" - "' ) + '"' ); + } jQuery.ajax( "./data/badjson.js" , { context: jQuery( "#success" ), dataType: "text" - }).success(function() { - console && console.log && console.log( "success/success" , arguments ); - this.addClass("success").text( "OK" ); - }).error(function() { - console && console.log && console.log( "success/error" , arguments ); - this.addClass("error").text( "FAIL" ); + }).success(function( data, _, xhr ) { + doLog( "Success (" + xhr.status + ")" , arguments ); + this.addClass( data ? "success" : "error" ).text( "OK" ); + }).error(function( xhr ) { + doLog( "Success (" + xhr.status + ")" , arguments ); + this.addClass( "error" ).text( "FAIL" ); }); jQuery.ajax( "./data/doesnotexist.ext" , { context: jQuery( "#error" ), dataType: "text" - }).error(function() { - console && console.log && console.log( "error/error" , arguments ); - this.addClass("success").text( "OK" ); - }).success(function() { - console && console.log && console.log( "error/success" , arguments ); - this.addClass( $.browser.opera ? "success" : "error" ).text( "FAIL" ); + }).error(function( xhr ) { + doLog( "Error (" + xhr.status + ")" , arguments ); + this.addClass( "success" ).text( "OK" ); + }).success(function( data, _, xhr ) { + doLog( "Error (" + xhr.status + ")" , arguments ); + this.addClass( "error" ).text( "FAIL" ); }); </script> </body>
\ No newline at end of file |