如何在不重新加载页面的情况下刷新div

时间:2016-04-19 06:11:46

标签: java html jstl

我从哪里有一个搜索框和提交按钮,我想在获取searchbox的值后刷新div

<form  action="/searchemp" method="post">
                                Employee <input type="text" name="EmployeeName" id="text1"/>
                                <input type ="submit" value="check"/>   
</form>

<div>       
        <table border="1">
            <thead> <h3 align="center">Selected Rule</h2>
                <tr>
                    <th data-field="id" width="30">ID</th>
                    <th data-field="details" width="20">RuleName</th>
                    <th data-field="parameter" width="180">Parameter&nbsp;|&nbsp; Value &nbsp;</th> 
                </tr>
            </thead>
            <c:forEach items="${List2}" var="as">
            <tr >
                <td>${as.id}</td>   
                <td>${as.ruleName}</td>
                <td>
                    <div>

                        <table>
                        <c:forEach items="${as.ruleParameter}" var="asss">  
                            <tr>
                                <td >${asss.parameterName} &nbsp;&nbsp;|&nbsp;&nbsp;</td>                                   
                                <td >${asss.parameterValue}</td>    
                            </tr>
                        </c:forEach>
                        </table>
                    </div>
                </td>           
            </tr>                           
            </c:forEach>    
    </table>
    </div>

我希望在提交后保留该搜索框值。我怎么能这样做...... ??请帮助我,

谢谢

2 个答案:

答案 0 :(得分:0)

您可以通过AJAX(http://api.jquery.com/load/)有用的链接

来完成此操作

可在此处找到更多信息(Refresh Part of Page (div)),之前的堆栈溢出

答案 1 :(得分:0)

使用XMLHttpRequest可以执行此操作

if (window.XMLHttpRequest) { // Mozilla, Safari, IE7+ ...
    httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE 6 and older
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}

httpRequest.open('GET', 'http://www.example.org/some.file', true);
httpRequest.send();

参考:https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started