使用jQuery刷新页面中的单个div元素? [英] Refreshing a single div element in a page with jQuery?

查看:263
本文介绍了使用jQuery刷新页面中的单个div元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在异步发布表单,我想在表单发布完成后刷新div元素.我已经编写了所有代码,但我只是不知道如何(甚至可能)以这种方式刷新单个div.有帮助吗?

I'm asynchronously posting a form, and I want to refresh a div element upon completion of the form post. I have everything coded already, I just don't know how to (and if it is even possible) to refresh a single div in this manner. Any help?

推荐答案

如果div的ID为"foo",并且您的数据名称为数据"

if the div has an id of "foo", and the name of your data is 'data'

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

这将在您的帖子或ajax调用的回调中

this would be in the callback of your post or ajax call

$.post(myURL, function (data) {
   $(#"foo").html(data);

}

这篇关于使用jQuery刷新页面中的单个div元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆