1 2$(document).ready(function() { 3 $('[data-ajax-html]').each(function(idx, value) { 4 ajaxWithoutAuth($(value).data('ajax-html'), null, 'GET', function(el) { 5 return function(data) { 6 $(el).html(data); 7 } 8 }(this)); 9 }); 10}); 11 12/** 13 * we CANNOT use jQuery's "cache: false" because it appends a "_" parameter which breaks Spring when it comes to binding. 14 */ 15function cachebust(data) { 16 if (data == null) { 17 data = new Object(); 18 } 19 20 if (typeof data === 'string') { 21 if (data.length > 0 && data.charAt(data.length - 1) != '&') { 22 data += '&'; 23 } 24 25 data += 'cachebust=' + new Date().getTime(); 26 } else { 27 data['cachebust'] = new Date().getTime(); 28 } 29 30 return data; 31} 32 33/** 34 * data can be something like $(form_selector).serialize() 35 * 36 * @param method e.g., 'POST' or 'GET' 37 */ 38function ajaxWithAuth(url, data, method, success, auth_handler) { 39 data = cachebust(data); 40 41 $.ajax(url, { 42 type : method, 43 data : data, 44 success : function(data, textStatus, jqXHR) { 45 console.log(jqXHR.getResponseHeader('auth_exception')); 46 47 if (jqXHR.getResponseHeader('auth_exception') == null) { 48 success(data, textStatus, jqXHR); 49 } else { 50 if (auth_handler === undefined) { 51 window.location.href = js_site_var['context_path'] + '/app/account/login'; 52 } else { 53 auth_handler(); 54 } 55 } 56 }, 57 error : function(jqXHR, text_status, error_thrown) { 58 console.log(jqXHR); 59 console.log(text_status); 60 console.log(error_thrown); 61 } 62 }); 63} 64 65function ajaxWithoutAuth(url, data, method, success, data_type) { 66 ajaxWithoutAuth(url, data, method, success, data_type, null); 67} 68 69/** 70 * data can be something like $(form_selector).serialize() this is just here for convenience, you don't have to call this 71 * function. 72 * 73 * @param method e.g., 'POST' or 'GET' 74 * @param data_type e.g., 'json' 75 */ 76function ajaxWithoutAuth(url, data, method, success, data_type, errorCallback) { 77 data = cachebust(data); 78 var opt = { 79 type : method, 80 data : data, 81 success : success, 82 error : errorCallback || function(jqXHR, text_status, error_thrown) { 83 console.log(jqXHR); 84 console.log(text_status); 85 console.log(error_thrown); 86 } 87 }; 88 89 if (typeof data_type !== 'undefined') { 90 91 // e.g. 'json' 92 opt.dataType = data_type; 93 } 94 95 $.ajax(url, opt); 96} 97 98/** 99 * data can be something like $(form_selector).serialize() this is just here for convenience, you don't have to call this 100 * function. 101 * 102 * can optionally pass in headers e.g.: 103 * {"Accept" : "application/json", "Content-Type" : "application/json"} 104 * 105 * @param method e.g., 'POST' or 'GET' 106 * @param data_type e.g., 'json' 107 */ 108function ajaxWithoutAuthWithHeaders(url, data, method, headers, success, data_type) { 109 data = cachebust(data); 110 111 var opt = { 112 type : method, 113 data : data, 114 headers : headers, 115 success : success, 116 error : function(jqXHR, text_status, error_thrown) { 117 console.log(jqXHR); 118 console.log(text_status); 119 console.log(error_thrown); 120 } 121 }; 122 123 if (typeof data_type !== 'undefined') { 124 125 opt.dataType = data_type; 126 } 127 128 $.ajax(url, opt); 129}
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.