繁体   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