简体   繁体   English

单击按钮时不显示我的loading.gif

[英]My loading.gif does not display on button click

I'm trying to create a loading screen whenever my button clicks, it executes the Ajax and everything but not the loading screen. 每当我的按钮单击时,我都试图创建一个加载屏幕,它会执行Ajax和所有内容,但不会执行加载屏幕。

CSS 的CSS

<style>
#display_loading{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, 50%);
}
</style>

jQuery jQuery的

$("#submit-btn").click(function(){
  //$('#loading').show();
  $("#display_loading").html('<img src="C:\Users\jmdsantos\Loading_icon.gif" height="100px" width="100px">')

And Below is for closing of the loading GIF through Ajax. 下面是通过Ajax关闭正在加载的GIF的信息。

$("#display_loading").html('')

Where did I go wrong? 我哪里做错了?

check your image path it not should be E&C both drive 检查您的图像路径,它不应该是E&C两个驱动器

E:C:\\Users\\jmdsantos\\Loading_icon.gif E:C:\\ Users \\ jmdsantos \\ Loading_icon.gif

Use only Loading_icon.gif if you are in jmdsantos folder. 如果您位于jmdsantos文件夹中,则仅使用Loading_icon.gif。

Your image tag is wrong. 您的图片标签有误。 It should not put in like that. 它不应该那样放。

It better to hide the image by id or any class using css and then display it on click function. 最好使用css按ID或任何类隐藏图像,然后在单击功能上显示它。

 $("#submit-btn").click(function(){ $("#display_loading").show(); }); 
  #display_loading{ position: absolute; top: 50%; left: 50%; transform: translate(-50%, 50%); display:none; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="display_loading"><img src="/path to/jmdsantos/Loading_icon.gif" height="100px" width="100px"></div> <button id="submit-btn">to click</button> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM