我有一个弹出窗口,其中有一个带有PopupDiv的id,我想在返回向Controller发出的Ajax请求后滚动顶部(当出现错误时,我返回带有Json的消息,我将其显示在弹出窗口)。我在网上找到了许多不同的方法,并尝试了下面的方法,但它们都没有工作(它们工作整个页面而不是弹出窗口)。有什么想法吗?
查看:
<div id="PopupDiv" style="height: 421px; overflow-y: scroll; margin-top: -7px; margin-bottom:-14px ">
<script>
$.ajax({
type: "POST",
url: '@Url.Action("Create", "Issue")',
data: formdata,
dataType: "json",
processData: false,
contentType: false,
success: function (response) {
if (!response.success) {
//I tried the following by one by one, but none of them is working:
messageThread.scrollTop = messageThread.scrollHeight;
$('html, form').animate({ scrollTop: $('#PopupDiv').position().top }, 'slow');
$(window).scrollTop(300);
$("html, body").animate({ scrollTop: "1024px" }, 5000);
var objDiv = document.getElementById("#PopupDiv");
objDiv.scrollTop = objDiv.scrollHeight;
}
}
});
</script>