Javascript div背景图像未更改

Javascript div背景图像未更改,javascript,jquery,html,ajax,razor,Javascript,Jquery,Html,Ajax,Razor,我有下面的HTML页面 您试图清除浏览器的缓存?您试图清除浏览器的缓存?找到了罪魁祸首,它正在缓存ajax调用,因此采用了相同的值,因此我将'cache:false' $.ajax({ type: "GET", url: '@Url.Action("GetProfilePictureValue", "Student")', data: { "StudentId": studentID }, dataType: "json",

我有下面的HTML页面


您试图清除浏览器的缓存?

您试图清除浏览器的缓存?

找到了罪魁祸首,它正在缓存ajax调用,因此采用了相同的值,因此我将
'cache:false'

 $.ajax({
        type: "GET",
        url: '@Url.Action("GetProfilePictureValue", "Student")',
        data: { "StudentId": studentID },
        dataType: "json",
        cache: false,
        success: function (newProfilePictureBase64Value)
        {
            $("#profilephoto").css('background', 'none');
            $('#profilephoto').css('background', 'url(data:image/png;base64,' + newProfilePictureBase64Value + ') no-repeat 50% 50%;');
            $("#profilephoto").load(location.href + " #profilephoto>*", "");

        },
        error: function ()
        {
            alert('Error occured');
        }
    });

找到了罪魁祸首,它缓存了ajax调用,所以取了相同的值,所以我把
'cache:false'

 $.ajax({
        type: "GET",
        url: '@Url.Action("GetProfilePictureValue", "Student")',
        data: { "StudentId": studentID },
        dataType: "json",
        cache: false,
        success: function (newProfilePictureBase64Value)
        {
            $("#profilephoto").css('background', 'none');
            $('#profilephoto').css('background', 'url(data:image/png;base64,' + newProfilePictureBase64Value + ') no-repeat 50% 50%;');
            $("#profilephoto").load(location.href + " #profilephoto>*", "");

        },
        error: function ()
        {
            alert('Error occured');
        }
    });
 $.ajax({
        type: "GET",
        url: '@Url.Action("GetProfilePictureValue", "Student")',
        data: { "StudentId": studentID },
        dataType: "json",
        cache: false,
        success: function (newProfilePictureBase64Value)
        {
            $("#profilephoto").css('background', 'none');
            $('#profilephoto').css('background', 'url(data:image/png;base64,' + newProfilePictureBase64Value + ') no-repeat 50% 50%;');
            $("#profilephoto").load(location.href + " #profilephoto>*", "");

        },
        error: function ()
        {
            alert('Error occured');
        }
    });