2021年3月22日星期一

ajaxStart won't load in Razor Shared page .Net 3.1

I am trying to load a gif spinner for all AJAX requests in my project and the problem that I am having is that it won't load at all.

Before that, I was including it on certain pages I needed but now I want to put it globally to all of my pages. It was working fine before this new change.

In other views in which I loaded the same piece of javascript, it would function adequately.

At this moment, I am including my ajaxStart and ajaxStop methods in a Razor page located in my Views\Shared\_NavBar_DataUser.cshtml

If anyone has ever had a similar problem to this one, it would be really appreciating if you would give me some sort of hint on how to resolve this issue.

   <nav>          <div id="divLoading" class="HideLoader">              <div>                  <img asp-append-version="true" src="~/Content/Img/loading.gif" />              </div>          </div>      </nav>      <!--Cargar Iframe Tarjeta Especialista -->      <iframe frameborder="0" src='' name="genericIframe" id="genericIframe" style="display:none;">        </iframe>    <script type="text/javascript">      let divLoadAjax = window.frames.top.document.getElementById("divLoading") ?? document.getElementById("divLoading");      console.log(divLoadAjax);      $(document).ready(function () {                   $(document).ajaxStart(function () {              let bodyHeight = $(divLoadAjax).closest("body").height();              $(divLoadAjax).height(bodyHeight * 2); // multiplicamos por 2 para que pueda ocupar todo el espacio de la ventana              $(divLoadAjax).show();              let mobileTablet = window.matchMedia('(max-width: 1025px)').matches;              if (!mobileTablet) {                  let profileNameHeight = document.querySelectorAll(".profile-name")[0].offsetHeight;                  let btnCvDoctorHeight = document.querySelectorAll(".btn-cv-doctor")[0].offsetHeight;                  let specTitleHeight = document.querySelectorAll(".btn-profile")[0].offsetHeight;                  let dayServiceHeight = document.querySelectorAll(".day-service")[0].offsetHeight;                  let buttonReservarMasCitasHeight = document.querySelectorAll(".input-group")[0].offsetHeight;                  let suma = 140 + profileNameHeight + btnCvDoctorHeight + specTitleHeight + dayServiceHeight + buttonReservarMasCitasHeight;                  $("#basicModal").css("height", suma);              }          }).ajaxStop(function () {              $(divLoadAjax).hide();          });      });  </script>  
https://stackoverflow.com/questions/66744827/ajaxstart-wont-load-in-razor-shared-page-net-3-1 March 22, 2021 at 07:06PM

没有评论:

发表评论