2.0: Remove JSON.parse shim
[jquery.git] / test / localfile.html
blob7d49c44e1bb92c9ddeb36aba78d2dc96d313c2e9
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">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>jQuery Local File Test</title>
6 <!-- Includes -->
7 <script src="../dist/jquery.js"></script>
8 <style>
9 .error { color: red; }
10 .success { color: green; }
11 </style>
12 </head>
13 <body>
14 <h1>jQuery Local File Test</h1>
15 <h2>
16 Introduction
17 </h2>
18 <ul>
19 <li>
20 Access this file using the "file:" protocol,
21 </li>
22 <li>
23 two green "OK" strings must appear below,
24 </li>
25 <li>
26 Empty local files will issue errors, it's a known limitation.
27 </li>
28 </ul>
29 <h2>
30 Results
31 </h2>
32 <ul>
33 <li>
34 Success:
35 <span id="success">
36 </span>
37 </li>
38 <li>
39 Error:
40 <span id="error">
41 </span>
42 </li>
43 </ul>
44 <h2>
45 Logs:
46 </h2>
47 <ul id="log">
48 </ul>
49 <script>
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" ),
56 dataType: "text"
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" );
63 });
64 jQuery.ajax( "./data/doesnotexist.ext" , {
65 context: jQuery( "#error" ),
66 dataType: "text"
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" );
73 });
74 </script>
75 </body>