I've a Yii2 project, and in my project I've script inside my php file that I used to send data and to show loading icon (.gif).
Script jQuery:
<script>
function displayResult() {
var x = document.getElementById('bootstrap-duallistbox-selected-list_CustomizeHeader[list_header][]');
document.getElementById("show").style.visibility = "visible";
if (x.length == 24) {
var txt = "";
var val = "";
for (var i = 0; i < x.length; i++) {
txt += x[i].text + ",";
val += x[i].value + ",";
}
window.location = 'result?txt=' + btoa(txt) + '&val=' + btoa(val);
} else {
alert("At least 24 Headers!");
}
}
</script>
Style CSS:
<style>
.no-js #loader { display: none; }
.js #loader { display: block; position: absolute; left: 100px; top: 0; }
#show{
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: url(../../web/img/ajax-loader6.gif) center no-repeat #fff;
}
</style>
Php Code:
<p>
<button type="button" onclick="displayResult()" class="btn btn-success">Process the headers</button>
</p>
<div id='show'></div>
You can see in my CSS, I call a .gif file. All code and script above successfully display the icon, but the icon showed as .jpg file. It doesn't show moving graphic (.gif).
Anyone know how to display icon .gif (moving graphic) in script?
Thanks
Edited:
I've try to use $("#loading").show(); or $("#loading").fadeIn();, and it give me nothing, this method didn't display the icon.
But if I use document.getElementById("loading").style.visibility = "visible";, it give me an icon displayed, but the icon didn't display as a .gif file, it's displayed as a .jpg file (non-moving graphic).
<div id="show"></div>javascript? Do you have anything onjquery?