in JavaScript
   <script>
           var xmlHttpRequest = new XMLHttpRequest();
           xmlHttpRequest.open("POST", '@Url.Action("****", "****")',true);
           xmlHttpRequest.onloadend = function() {
               @{
                     var res = (UserResponseMvc) TempData["UserResponse"];  
                }
                @Html.ShowAlert(res?.Message)
           }
           xmlHttpRequest.send();
   </script>
in Controller
public ActionResult Upload() {
       //code
        TempData["UserResponse"] = new UserResponseMvc
        {
            Success = true,
            Message = "Upload Success"
        };
        return View();
}
In this piece, the code does not know the res variable.
How can I use the res variable here?
I write in Asp.net Mvc code.
Pls help me.
 
    