Jquery 在ajax上加载php文件成功
我有一门叫新闻的课。它包含一些来自用户的更新。当用户提交新更新时,我希望此新更新显示在news类的顶部,因为它是新的 我尝试了以下方法,但没有按我想要的方式工作。提交表单时,会加载latestpost.php,但news div会消失(因为我的prepend()为空)Jquery 在ajax上加载php文件成功,jquery,ajax,Jquery,Ajax,我有一门叫新闻的课。它包含一些来自用户的更新。当用户提交新更新时,我希望此新更新显示在news类的顶部,因为它是新的 我尝试了以下方法,但没有按我想要的方式工作。提交表单时,会加载latestpost.php,但news div会消失(因为我的prepend()为空) 尝试将$.ajax()替换为.load(),利用上下文设置将$(“.news”)作为值 $.ajax({ type:"GET", url:"/modules/feed/latestpost.php", context:
尝试将
$.ajax()
替换为.load()
,利用上下文设置将$(“.news”)
作为值
$.ajax({
type:"GET",
url:"/modules/feed/latestpost.php",
context:$(".news") // `$(".news")` : `this` within `.then()`
})
.then(function(data) {
this.prepend(data); // `this`:`$(".news")`
}, function(jqxhr, textStatus, errorThrown) {
console.log(errorThrown)
});
尝试将$.ajax()
替换为.load()
,利用上下文设置将$(“.news”)
作为值
$.ajax({
type:"GET",
url:"/modules/feed/latestpost.php",
context:$(".news") // `$(".news")` : `this` within `.then()`
})
.then(function(data) {
this.prepend(data); // `this`:`$(".news")`
}, function(jqxhr, textStatus, errorThrown) {
console.log(errorThrown)
});
尝试将$.ajax()
替换为.load()
,利用上下文设置将$(“.news”)
作为值
$.ajax({
type:"GET",
url:"/modules/feed/latestpost.php",
context:$(".news") // `$(".news")` : `this` within `.then()`
})
.then(function(data) {
this.prepend(data); // `this`:`$(".news")`
}, function(jqxhr, textStatus, errorThrown) {
console.log(errorThrown)
});
尝试将$.ajax()
替换为.load()
,利用上下文设置将$(“.news”)
作为值
$.ajax({
type:"GET",
url:"/modules/feed/latestpost.php",
context:$(".news") // `$(".news")` : `this` within `.then()`
})
.then(function(data) {
this.prepend(data); // `this`:`$(".news")`
}, function(jqxhr, textStatus, errorThrown) {
console.log(errorThrown)
});
您可以在process的响应中返回最新帖子。phpYou可以在process的响应中返回最新帖子。phpYou可以在process的响应中返回最新帖子。phpYou可以在process.php的响应中返回最新帖子