I have popup window and there is a in it with the id of PopupDiv and I want to scroll top after returning the Ajax request made to the Controller (when there is an error, I return message with Json and I display it on the popup window). I have found many different ways on web and tried the methods below, but none of them is not working (they works a whole page instead of popup window). Any idea?
View:
<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>