我正在尝试使用ajax html响应中的内容更新div.我相信我的语法正确,但div内容被替换为整个HTML页面响应,而不仅仅是在html响应中选择的div.我究竟做错了什么?
<script>
$('#submitform').click(function() {
$.ajax({
url: "getinfo.asp",
data: {
txtsearch: $('#appendedInputButton').val()
},
type: "GET",
dataType : "html",
success: function( data ) {
$('#showresults').replaceWith($('#showresults').html(data));
},
error: function( xhr, status ) {
alert( "Sorry, there was a problem!" );
},
complete: function( xhr, status ) {
//$('#showresults').slideDown('slow')
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)