从服务器响应操作DOM

时间:2015-04-15 05:21:32

标签: javascript jquery html dom

我有一个HTML页面,它发送查询并使用JQuery的POST($ .post()。done())从服务器获取响应

<!doctype html>
<html>
<head>
    <script src="jquery-1.11.2.min.js"></script>
</head>
<body>

<center>
    <div>
    <h3>Web Service Search Engine </h3>
    <input type="textbox" name="UserQuery" id="UserQuery" size="70"></br></br>
    <button type="button" onclick="search()">Search</button>
    </div>
</center>
<div id="Results">
</div>
<script>
function search()
{
    $.post("Check.php", {
        UserQuery:  $("#UserQuery").val()

    })
  .done(function(data) {

    })
}
</script>

</body>
</html>

来自Check.php的响应是一些已经格式化的链接

<a href="Crawled WSDL Documents/21272_United_States_shortlynx.wsdl">Crawled WSDL Documents/21272_United_States_shortlynx.wsdl</a><br/>
<a href="Crawled WSDL Documents/16932_United_States_dailycomicsservice.wsdl">Crawled WSDL Documents/16932_United_States_dailycomicsservice.wsdl</a><br/>
<a href="Crawled WSDL Documents/15465_United_States_measurementconversions.wsdl">Crawled WSDL Documents/15465_United_States_measurementconversions.wsdl</a><br/>
<a href="Crawled WSDL Documents/14242_United_States_converter.wsdl">Crawled WSDL Documents/14242_United_States_converter.wsdl</a><br/>
<a href="Crawled WSDL Documents/17606_Spain_conversor.wsdl">Crawled WSDL Documents/17606_Spain_conversor.wsdl</a><br/>

如何将此响应放在带有id = Results ??

的DIV标记内

2 个答案:

答案 0 :(得分:1)

我不想欺骗评论员。我只是把它作为答案

$("#Results").html(data);

致Brijesh Bhatt的信用

答案 1 :(得分:1)

这样可行

...

.done(function(data) {
  $('#Results').html(data);
})