weixin_33726313 2011-07-04 15:41 采纳率: 0%
浏览 46

JavaScript / Ajax firefox 3.0.x

I have a problem with JS or Ajax (I don't know).

I have a button on a web page (html) that is associated with a JS onClick event. This JS works fine for every browser execpt firefox 3.0.x

I don't know where the problem is.

I attach the code so someone can tell me something about that.

Thank you in advance.

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.

";
    messaggioFooter['it'] = "
Continuare 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. 

"
    messaggioFooter['en'] = "
Do 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 != "
" )
    {
        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);
  }
} 

I've just found the solution. Firefox < 4 doesn't support ajax synchronous handler. If i switch to async. handler it works in the right way.

  • 写回答

1条回答 默认 最新

  • weixin_33743880 2011-07-04 15:48
    关注

    Replace this:

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

    with this:

    var messaggioHeader = {};
    var messaggioFooter = {};
    
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题