1

这是我的 JSON 函数 *我的 userId 如下*

var userId = '@(ViewBag.UserId)';
        function getMessage(userId) {
            $.ajax(
                 {
                     type: "Post",
                     url: "/Message/GetMessage",
                     dataType: "json",
                     data: { "recieverUsersId": userId },
                     async: true,
                     cache:true,
                     success: function (data) {
                         var div = $('#msg');
                         div.html("");
                         $.each(data.messages, function (i, item) {
                         div.append('<li id="reply"><img src="' + item.FileAttachedURL + '" style="height:auto; width:100%; margin-left:auto; margin-right:auto; "/></li>')
                         }, 
                         error: function (req, status, error) {
                         var div = $('#comment');
                         div.html("");
                         div.append('Error');
                     }
                 });
     }

将 JSON 数据更新为时间间隔

     function getValue() {
         var userId = $('#recieverUserId').val();
         getMessage(userId)
         function myStopFunction() {
             clearInterval(myVar);
         }
     }

设置 getMessage 函数的时间间隔

     var refresh = setInterval(function () { getValue() }, 5);
     function myStopFunction() {
         clearInterval(refresh);
     }

问题:当我从表格中获取图像时,图像也在时间间隔内闪烁。为什么我会遇到这个问题,或者是否有任何其他解决方案可以在特定时间段内更新数据

4

0 回答 0