If the two variables are equal 6s ==6s
, Secdata
Images need to load ELSE loading GIF I should show
I'm using MongoDB. My array object
"sec": "6s"
"Secdata" : ["1.jpg", "2.jpg"];
I have four buttons in HTML element
<a href="" data-sec="4s">4s</a>
<a href="" data-sec="6s">6s</a>
<a href="" data-sec="8s">8s</a>
<a href="" data-sec="10s">10s</a>
When I click 6s
button. It will take 6s data value and compare with a collection data sec
.
$(document).ready(function() {
function checkAjax(id, tmax, tid, pid) {
$.ajax({
url: '../tmax',
type: 'POST',
data: {
id: id,
tmax: tmax,
tid: tid,
pid: pid
},
success: function(response) {
$("#sliderA").hide();
$("#sliderB").hide();
$("#sliderC").hide();
$("#tmaxsecsdata").html(response);
if (second == tmax) {
checkAjax(id, tmax, tid, pid);
} else {
var loadinggif = "<img src='loader.gif' class='img-responsive'>";
$("#tmaxsecsdata").html(loadinggif);
}
},
error: function() {
console.log("Error");
}
})
}
$(".secs li a").on("click", function(e) {
e.preventDefault();
var id = $(this).data("jsonid");
var tmax = $(this).data("secs");
var tid = $(this).data("tid");
var pid = $(this).data("pid");
checkAjax(id, tmax, tid, pid);
})
})
The second variable, I'm getting from the backend
My problem
When clicking my button, I'm getting a variable (6s
=> it will be anything 4s,8s,10s,4s). Same like that, I'm getting another variable in my collection. Now I have two variable, This two variables I use to compare ('6s' => it will be anything 4s,8s,10s,4s). If the two variables or not equal, The loader will show on my page. An hour after in my collection will get an update and I will get equal variable. Now I need sho the images.
Thanks