I have an array of users. Each user can be skipped on .click button. However I want it to skip the user that logs in. The session is started with PHP, but I'm showing the user through ajax and javascript. However
if(sSession = sKey){
aPeople.slice(this.jPerson);
}
is not correctly skipping the user. Could you help?
Here's the code:
$("#btnSkip").click(function() {
$.getJSON('include/users.txt', function(aPeople){
var getPerson = function(id) {
var jPerson = aPeople[id]
var sID = jPerson.id
var sName = jPerson.name
var sImage = jPerson.picture
var sSession = $('#mySession').text()
var sKey = jPerson.key
//this if statement doesn't work
if(sSession == sKey){
console.log(sSession)
console.log(sKey)
console.log(personIndex)
console.log(jPerson)
aPeople.splice(jPerson);
}
$('#sName').text(sName)
$('#sImg').attr('src', sImage)
//TO START COUNT AGAIN
if(aPeople.length -1 == personIndex){
personIndex = 0
}else{
personIndex = personIndex + 1
}
}
getPerson(personIndex);
$( '#sName' ).fadeIn( 'slow' )
$( '#sImg' ).fadeIn( 'slow' )
})
})