【发布时间】:2020-08-27 19:00:45
【问题描述】:
I have a View as shown below
**<div id = 123 class ="Country">**
<div class = "content">
**<need to load partial view here>**
</div>
**</div>**
**<div id = 234 class ="Country">**
<div class = "content">
**<need to load partial view here>**
</div>
**</div>**
...
...More div's here
...
so on clicking the Country div, i need to load its inner div "content". My jQuery ajax call is like below
$(".country").on('click', function () {
$.ajax({
url: '@(Url.Action("FilesByCountry", "RelatedFiles"))', //Cont & ActionResult
type: "GET",
data: $(this).attr('id'), //getting the click id
contentType: "application/json; charset=utf-8",
success: successFunc,
error: errorFunc
});
function successFunc(data) {
**$(this).attr('id').children($('#content', data).html())**
}
function errorFunc(xhr, errorType, exception) {
alert(xhr.status + ": " + exception);
}
});
});
所以控制器运行良好,它在调试模式下通过了 PartialView。但是部分视图在主视图中没有绑定。对此有什么想法吗?
【问题讨论】:
-
如果你使用--> .html(data),你会得到内容吗?
-
如果我成功输入警报(数据)然后我看到部分视图 html 绑定...所以现在我的问题是如何查找/绑定 id 的孩子的“内容”div
标签: javascript jquery asp.net-mvc asp.net-mvc-4 dom