簡體   English   中英

添加新選項時自動刷新選擇框

[英]Auto refresh select box when new option added to it

當我在運行時將數據添加到選擇框時,頁面無法自動刷新時遇到了問題。 我必須手動刷新頁面,才能用新添加的選項值填充選擇器。

在此處輸入圖片說明

現在,當我單擊“選擇器”中的“ ...”虛線按鈕時,將打開一個彈出窗口

在此處輸入圖片說明

如果我在此彈出窗口中添加值,則不會反映在我的選擇器中。 請幫我。 我想自動刷新選擇框

編輯:我的JSP代碼:

<TD ALIGN="LEFT">
    <fdms:speedselect name="firstCallInformation" property="placeDeath" category="LOCDEATH" column="1"
            combo="true" maxlength="50" size="1" textsize="30">
    <fdms:linkoption text="Edit list..." script="tableWindow2('LOCDEATH',1,'firstCallInformation.placeDeath')" />
    <fdms:targetfield column="2" property="locationDeceased" />
    <fdms:targetfield column="3" property="placeDeathCity" />
    <fdms:targetfield column="6" property="placeDeathState" />
    <fdms:targetfield column="7" property="placeDeathZip" />
    <fdms:targetfield column="8" property="locDeathLicenseNumber" />
    </fdms:speedselect>
</TD>

我正在使用某種ajax調用,但不確定是否正確

function loadFacility(callback)
            {
                alert('In loadFacility');
                var xmlhttp;
                var keys=document.firstCallInformation.facilityselect.value;
                var urls="localhost:8080/webfdms/showFirstCallInformation.do?vitalsId=366";
                if (window.XMLHttpRequest)
                {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {// code for IE6, IE5
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange=function()
                {
                    if (xmlhttp.readyState==4 && xmlhttp.status == 200)
                    {
                         //var some=xmlhttp.responseXML.documentElement;
                        var resposne = xmlhttp.responseText;
                        alert(resposne);
                        callback(xmlhttp.responseText);
                    }
                }
                xmlhttp.open("GET",urls,true);
                xmlhttp.send(null);
            }
            function loadFacilityCallback(resposne){
                if(resposne != null){
                    alert(resposne);
                }
            }

並像這樣調用它:

<fdms:speedselect property="facility" category="FacilityPlace" maxlength="50" column="1" combo="true" size="1" textsize="60" onchange="loadFacility(callback)">

我猜測更新已在服務器上完成? 該jsp將被編譯到一個servlet中,該servlet將呈現HTML頁面,而該頁面又將存在於瀏覽器中。 HTTP是無狀態協議,因此,在沒有其他請求的情況下,jsp頁面將不會知道已進行更改。

如果是這種情況,您可以選擇:

  • 使用HTTP / 2
  • 使用WebSockets
  • 使用Ajax請求更改來輪詢服務器

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM