1;ailtire.ajax = function() { 2 var 3 4 //flag indicating page is unloading, ajax errors are suppressed if true 5 mUnloading = false, 6 7 //error message displayed when an ajax error occurs. 8 mErrorMsg = "An error has occurred", 9 10 // 11 //init 12 // 13 init = function() { 14 //Setup default for ajax errors 15 $.ajaxSetup({ 16 error: function(XMLHttpRequest, textStatus, errorThrown) { 17 if (!mUnloading) { 18 alert(mErrorMsg + ": " + errorThrown); 19 } 20 } 21 }); 22 23 //set the unloading flag when leaving the page. 24 $(window).bind("beforeunload", function() { 25 mUnloading = true; 26 }); 27 28 }, 29 30 31 // 32 //post to an mvc controller 33 // 34 post = function (url, data, callback) { 35 //This one works with complex json objects 36 $.ajax({ 37 type: 'post', 38 url: url, 39 data: JSON.stringify(data), 40 contentType: "application/json; charset=utf-8", 41 traditional: true, 42 success: function (result) { 43 if (!checkTimeout(result)) { 44 if (callback) { 45 callback(result); 46 } 47 } 48 } 49 }); 50 }, 51 52 // 53 //synchronous post to MVC controller 54 // 55 postSync = function (url, data) { 56 //$.post( 57 // url, 58 // data 59 //); 60 61 var ret = null; 62 63 //This one works with complex json objects 64 $.ajax({
65 type: 'post', 66 async: false, 67 url: url, 68 data: JSON.stringify(data), 69 contentType: "application/json; charset=utf-8", 70 traditional: true, 71 success: function (result) { 72 //if (!checkTimeout(result)) { 73 ret = result; 74 //} 75 } 76 }); 77 78 return ret; 79 }, 80 81 // 82 //get from a controller url 83 // 84 get = function (url, callback) { 85 //This one works with complex json objects 86 $.get( 87 url, 88 function (result) { 89 if (!checkTimeout(result)) { 90 if (callback) { 91 callback(result); 92 } 93 } 94 } 95 ); 96 }, 97 98 // 99 //see if timeout was returned by ajax, returns the timeout url if session has timed out 100 // 101 checkTimeout = function(result) { 102 if (result && typeof(result) == "object" && result.TimeoutUrl) { 103 window.location = result.TimeoutUrl; 104 return true; 105 } else { 106 return false; 107 } 108 }; 109 110 //call init 111 $(document).ready(init); 112 113 return { 114 post: post, 115 postSync: postSync, 116 get: get 117 }; 118}();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.