Javascript Ajax返回完整结构的html,而不仅仅是特定div的数据
您好,我使用ajax重新加载div内容,而不重新加载整个页面,因为我使用以下代码Javascript Ajax返回完整结构的html,而不仅仅是特定div的数据,javascript,jquery,html,css,ajax,Javascript,Jquery,Html,Css,Ajax,您好,我使用ajax重新加载div内容,而不重新加载整个页面,因为我使用以下代码 $.post(window.location,{llrating:ratingvalue},function(){ //alert("Thanks for rating"); //location.reload(); $(".header-search").load(location.href + " .header-search"); }); 现在它工作
$.post(window.location,{llrating:ratingvalue},function(){
//alert("Thanks for rating");
//location.reload();
$(".header-search").load(location.href + " .header-search");
});
现在它工作正常,但它复制了整个内容,例如,如果我想刷新我的div
<div class="content"></div>
然后刷新div,但结果是这样的
<div class="content"><div class="content"></div></div>
希望你明白我想说的话 使用片段加载时 $(“#result”).load(“ajax/test.html#container”)
当这个方法 执行时,它检索ajax/test.html的内容,然后是jQuery 解析返回的文档以查找ID为的元素 容器。此元素及其内容将插入到 元素,以及检索到的文档的其余部分 被丢弃 因此,将
内容
元素加载到标题搜索
$(".header-search").load(location.href + " .header-search .content");
我想您需要
$(“.header search.content”).load(location.href+”.header search.content)代码>我已经尝试过了,但我的问题是它正在重新加载和复制div,因为我在上面的问题中给出了一个例子。你可以看看lol,不要ajax整个页面只是为了一个评级值,ajax只是评级值我知道兄弟我也这么做了,但它是在同一个div中插入div