1 2// AJAX i redir 3// http://api.jquery.com/ 4// http://cheat.errtheblog.com/s/jquery 5 6 7/** 8@class call 9*/ 10(function($) { 11 12 /** 13 call(action, params) 14 @function call 15 @param action strutus action or jsp, php, etc. called 16 @param params JSON or string param 17 @return JSON or string response 18 */ 19 $.call = function(action, params) { 20 21 var res = ""; 22 var resj; 23 var firstChar; 24 25 if (!params) 26 params = {}; 27 28 var rp = location.protocol + '//' + location.host+'/'; 29 /*if (!(typeof(_rp_) === undefined)){ 30 rp = _rp_ + "/"; 31 } */ 32 33// var urlAction = action.split('.')[0] + '?_op=' + action.split('.')[1]; 34 var urlAction = 'delegate/Not_uc?_op=' + action; 35 36 params._ts = new Date().getTime(); 37 38 if (typeof(params) == 'string'){ 39 firstChar = $.trim(params).substring(0, 1); 40 if (firstChar == '{' || firstChar == '['){ 41 res = $.ajax({url: rp + urlAction, type: 'POST', data: '_json=' + params, async: false, contentType:"application/x-www-form-urlencoded; charset=UTF-8"}).responseText; 42 }else{ 43 res = $.ajax({url: rp + urlAction, type:'POST', data: params, async: false, contentType:"application/x-www-form-urlencoded; charset=UTF-8"}).responseText; 44 } 45 }else{ 46 res = $.ajax({url: rp + urlAction, type: 'POST', data: '_json=' + JSON.stringify(params), async: false, contentType:"application/x-www-form-urlencoded; charset=UTF-8"}).responseText; 47 } 48 49// alert(res); 50 firstChar = $.trim(res).substring(0, 1); 51 if (firstChar == '{' || firstChar == '['){ 52 try{ 53 var resp = eval('(' + res + ')'); 54 resj = resp._obj; 55 if (resp._msg != ''){ 56 alert('Msg del servidor: |' + resp._msg + '|'); 57 } 58// alert('>>>' + res); 59 } catch (e) { 60 alert(res); 61 } 62 }else{ 63 resj = res; 64 } 65 66 return resj ? resj : {}; 67 }; 68 69 70 $.calla = function(action, params, callBack) { 71 72 if (!params) 73 params = {}; 74 75 var rp = ""; 76 if (!(typeof(_rp_) === undefined)){ 77 rp = _rp_ + "/"; 78 } 79 80// var urlAction = action.split('.')[0] + '?_op=' + action.split('.')[1]; 81 var urlAction = '_uc?_op=' + action; 82 83 84 params._ts = new Date().getTime(); 85 86 if (typeof(params) == 'string'){ 87 firstChar = $.trim(params).substring(0, 1); 88 if (firstChar == '{' || firstChar == '['){ 89 if (callBack) 90 $.ajax({url: rp + urlAction, type: 'POST', data: '_json=' + params, async: true, success: callBack}); 91 else 92 $.ajax({url: rp + urlAction, type: 'POST', data: '_json=' + params, async: true}); 93 }else{ 94 if (callBack) 95 $.ajax({url: rp + urlAction, type:'POST', data: params, async: true, success: callBack}); 96 else 97 $.ajax({url: rp + urlAction, type:'POST', data: params, async: true}); 98 } 99 }else if(typeof(params) == 'function'){ 100 var params2 = {}; 101 params2._ts = new Date().getTime(); 102 $.ajax({url: rp + urlAction, type: 'POST', data: params2, async: true, success: params}); 103 }else{ 104 $.ajax({url: rp + urlAction, type: 'POST', data: '_json=' + JSON.stringify(params), async: true, success: callBack}); 105 } 106 }; 107 108 109 /** 110 redir(action, params) 111 @function redir 112 @param action strutus action or jsp, php, etc. called 113 @param params in form-url-encoded 114 */ 115 $.redir = function(url) { 116 var symb = '?'; 117 118 if (url.indexOf('?') >= 0) 119 symb = '&'; 120 121 window.location = url + symb + '_ts=' + new Date().getTime(); 122 }; 123 124})(jQuery); 125 126
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.