1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en" lang=
"en" dir=
"ltr" id=
"html">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
5 <title>jQuery Local File Test
</title>
7 <script src=
"../dist/jquery.js"></script>
10 .success { color: green; }
14 <h1>jQuery Local File Test
</h1>
20 Access this file using the
"file:" protocol,
23 two green
"OK" strings must appear below,
26 Empty local files will issue errors, it's a known limitation.
50 var logUL
= jQuery( "#log" );
51 function doLog( message
, args
) {
52 jQuery( "<li />").appendTo( logUL
).text( message
+ ': "' + Array
.prototype.join
.call( args
, '" - "' ) + '"' );
54 jQuery
.ajax( "./data/badjson.js" , {
55 context
: jQuery( "#success" ),
57 }).success(function( data
, _
, xhr
) {
58 doLog( "Success (" + xhr
.status
+ ")" , arguments
);
59 this.addClass( data
? "success" : "error" ).text( "OK" );
60 }).error(function( xhr
) {
61 doLog( "Success (" + xhr
.status
+ ")" , arguments
);
62 this.addClass( "error" ).text( "FAIL" );
64 jQuery
.ajax( "./data/doesnotexist.ext" , {
65 context
: jQuery( "#error" ),
67 }).error(function( xhr
) {
68 doLog( "Error (" + xhr
.status
+ ")" , arguments
);
69 this.addClass( "success" ).text( "OK" );
70 }).success(function( data
, _
, xhr
) {
71 doLog( "Error (" + xhr
.status
+ ")" , arguments
);
72 this.addClass( "error" ).text( "FAIL" );