使用Ajax调用的结果更新div
我想将下面的ajax函数的响应显示给dom中的div(更新div)。 如何在不使用重插件的情况下完成此操作。
url: 'http://dowmian.com/xs1/getcam.php', type: 'GET', data: {id: }, success: function(responseText){ }, error: function(responseText){ }
它取决于你的getcam.php
函数的返回值,但你可能正在寻找html()
函数:
$.ajax({ url: 'http://dowmian.com/xs1/getcam.php', type: 'GET', data: {id: }, success: function(responseText){ $('#update-div').html(responseText); }, error: function(responseText){ } });
如果你想动态地追加#update-div
,就像在ajax调用之前一样,你可以使用append()
来做到这一点:
$('.container').append($('').attr('id','update-div'));
参考文献 :
-
ajax()
-
html()
-
append()
内部成功,这样做:
success: function(responseText) { $("#target").text(responseText); },
试试这个:
success: function(responseText) { $("#update-div").text(responseText.d); },
您可以从这里获得更多信息
利用您拥有的空“成功”处理函数。