1/* Funzioni generiche di base utilizza la libreria jQuery */ 2 3// ------------------------------------------------------------ 4// # Effettua la richiesta al server 5// sBody: la stringa che contiene il Body del Form 6// method: metodo submit 7// action: pagina a cui effettua la richiesta 8// Async: tipo di chiamata al server 9// functionAsyncOK: funzione eseguita se la chiamata asincrona è terminata con successo 10// userContext: variabili che vengono utilizzate dalla functionAsyncOK (es. nome del div da riempire) 11function execRequest(sBody, method, action, Async, functionAsyncOK, userContext) { 12 13 if (Async) 14 { 15 $.ajax({ 16 type: method.toUpperCase() , 17 url: action, 18 data: sBody, 19 async: true, 20 error: function(request, status, error) { 21 getFunctionAsyncError(request, status, error); 22 }, 23 success:(function(resultData) { 24 eval(functionAsyncOK + "(resultData, '" + userContext + "')"); 25 }) 26 }); 27 } 28 else 29 { 30 var resultData = $.ajax({ 31 type: method.toUpperCase(), 32 url: action, 33 data: sBody, 34 async: false 35 }).responseText; 36 37 return resultData; 38 } 39 40} 41 42// ------------------------------------------------------------ 43// # Effettua la richiesta sincrona al server 44// sBody: la stringa che contiene il Body del Form 45// method: metodo submit 46// action: pagina a cui effettua la richiesta 47function execRequestSj(sBody, method, action) { 48 return execRequest(sBody, method, action, false, "", ""); 49} 50/* Funzioni generiche per form */ 51 52// ------------------------------------------------------------ 53// # Ricava il contenuto dei campi Input del Form 54// oForm: oggetto Form 55function getRequestBody(oForm) { 56 var aParams = new Array(); 57 58 // effettua un ciclo su tutti i campi Input del Form 59 for (var i=0; i < oForm.elements.length; i++ ) { 60 // crea un vettore in cui ogni elemento è: "NomeCampo=ValoreCampo" codificato per l'utilizzo nel URL 61 // NB: encodeURIComponent è il metodo consigliato, ma corrompe i caratteri accentati 62 var sParam = escape(oForm.elements[i].name); 63 64 sParam += "="; 65 66 //alert(oForm.elements[i].name); 67 //alert(oForm.elements[i].value); 68 //alert(escape(oForm.elements[i].value)); 69 70 sParam += escape(oForm.elements[i].value); 71 aParams.push(sParam); 72 } 73 74 // restituisce il vettore sottoforma di stringa "NomeCampo1=ValoreCampo1&NomeCampo2=ValoreCampo2" 75 return aParams.join("&"); 76} 77 78function getFunctionAsyncError(request, status, errMsg) { 79 80 if (request.status!=0) 81 { 82 alert("ATTENZIONE: Si è verificato un errore interno. Il caricamento verrà interrotto. (" + errMsg + ")"); 83 } 84 chkAjaxError = true; 85}
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.