2011-07-04 16 views
0

JSやAjaxに問題があります(わかりません)。JavaScript/Ajax firefox 3.0.x

私はJS onClickイベントに関連付けられているWebページ(HTML)のボタンを持っています。このJSは、すべてのブラウザのexecptのFirefox 3.0.xを

問題がどこにあるか私にはわからないため正常に動作します。

誰かが私にそれについて何かを教えることができるように、コードを添付します。

ありがとうございます。

S.

var currLanguage = "en"; 
var request; 
var queryString; 

function confermaSalvataggio(reservationsList) 
{ 
    var messaggioHeader = new Array(); 
    var messaggioFooter = new Array(); 
    messaggioHeader['it'] = "ATTENZIONE! I dati caricati nel pannello non sono più aggiornati a causa di prenotazioni o cancellazioni avvenute dall'apertura del pannello stesso.\n\n"; 
    messaggioFooter['it'] = "\nContinuare con le VOSTRE modifiche ? Premendo OK i vostri dati verranno salvati e dovrete verificarne la correttezza in seguito manualmente. Premendo ANNULLA (consigliato) verrete riportati al pannello dove potrete appuntarvi i dati appena inseriti, ricaricare il pannello (manualmente) ed inserirli nuovamente mantenendo il loro stato congruente con le prenotazioni/cancellazioni appena giunte"; 
    messaggioHeader['en'] = "CAUTION! Data loaded on the panel isn't up to date due to reservations or cancellations occurred since panel open. \n\n" 
    messaggioFooter['en'] = "\nDo you want to continue with changes ? By clicking OK YOUR data will saved and, then, you'll have to verify the correctness in a manual way. By clicking CANCEL (recommended) you'll come back on the panel where you can clip out data just inserted, reload the panel (manually) and insert again data keeping data state congruent with reservations/cancellations just come"; 
    messaggioHeader['fr'] = messaggioHeader['en']; 
    messaggioFooter['fr'] = messaggioFooter['en']; 
    messaggioHeader['es'] = messaggioHeader['en']; 
    messaggioFooter['es'] = messaggioFooter['en']; 
    messaggioHeader['de'] = messaggioHeader['en']; 
    messaggioFooter['de'] = messaggioFooter['en']; 

    if (reservationsList != "\n") 
    { 
     var messaggio = messaggioHeader[currLanguage]+reservationsList+messaggioFooter[currLanguage]; 
     var flag = confirm(messaggio); 
     if (flag) 
     { 
      document.tariffe.submit(); 
     } 
    } 
    else 
    { 
     document.tariffe.submit(); 
    } 
} 

function handleSaveResponse() 
{ 
    if (request.readyState == 4) 
    { 
    if (request.status == 200) 
    { 
     var response = this.responseText; 
     confermaSalvataggio(response); 
    } 
    else 
    { 
     //alert("Risposta del web service: " + request.status); 
    } 
    } 
} 

function initializeRequestObject() 
{ 
    var msxmlhttp = new Array('Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'); 

    if (typeof XMLHttpRequest != "undefined") 
    { 
    request = new XMLHttpRequest(); 
    } 
    else 
    { 
    for (var i = 0; i < msxmlhttp.length; i++) 
    { 
     try 
     { 
     request = new ActiveXObject(msxmlhttp[i]); 
     } 
     catch (e) 
     { 
     request = null; 
    } 
    } 
    } 
} 

function initReq(reqType, url, bool) 
{ 
    if (request) 
    { 
    try 
    { 
     request.open(reqType, url, bool); 
    } 
    catch (e) 
    { 
     errorsString = 'Errore nella funzione initReq(), metodo request.open: ' + e; 
     alert(errorsString); 
    } 

    try 
    { 
     request.onreadystatechange = handleSaveResponse; 
     request.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); 
    } 
    catch (e) 
    { 
     errorsString = "Errore nella funzione initReq(), metodo request.onreadystatechange: " + e; 
     alert(errorsString); 
    } 

    try 
    { 
     request.send(queryString); 
    } 
    catch (e) 
    { 
     errorsString = "Errore nella funzione initReq(), metodo request.send: " + e; 
     alert(errorsString); 
    } 
    } 
} 


function httpRequest(reqType, url, asynch) 
{ 
    initializeRequestObject(); 
    if (request) 
    { 
    initReq(reqType, url, asynch); 
    } 
    else 
    { 
    notifyError("Errore in httpRequest(): oggetto XmlHttpRequest non inizializzato correttamente"); 
    } 
} 


function controlReservations(hotel_id,data_server,data_da,data_a,lingua) 
{ 
    try 
    { 
    queryString = "hid=" + hotel_id + "&ds=" + data_server + "&dd=" + data_da + "&da=" + data_a + "&lingua=" + lingua; 
    httpRequest("POST", "hotelLastReservations", false); 

    // MI SERVIRANNO !?!? // 
    //pagina = base_url + "/" + entity 
    //alert(pagina); 
    //window.location = pagina; 
    // MI SERVIRANNO !?!? // 
    } 
    catch (e) 
    { 
    notifyError("Errore in toggleAttiva(): " + e); 
    } 
} 

は、私はちょうど解決策を見つけました。 Firefox < 4はajax同期ハンドラをサポートしていません。私は非同期に切り替えます。ハンドラは正しい方法で動作します。

+0

:?これで

var messaggioHeader = new Array(); var messaggioFooter = new Array(); 

を –

+0

「あなたのブラウザはベンダーによってサポートされておらず、既知のセキュリティ問題とこのサイトの既知のバグがあります。最新のバージョンにすぐにアップグレードすることをお勧めします。 – Quentin

+1

名前付きキーが必要な場合は、オブジェクトを使用して配列を使用しないでください。あなたが一連の数字キーを持っているときのための配列。 – Quentin

答えて

0

この置き換え:あなたは、どのエラーが出るん

var messaggioHeader = {}; 
var messaggioFooter = {}; 
+0

私たちの意見では互換性がありません?私は試してみてください、 – DonCallisto

+0

それは働いていません... – DonCallisto

+0

htmlスニペットを追加できますか?クロスブラウザのAjaxメソッドを使用しないでください。騒々しいですし、問題解決に役立つものは何も持っていません –

関連する問題