am building a voting application in which a particular voter with an email address can only vote once however the code i have here runs too slow please how the i covert the following code to $http.post angular code that returns a response that i can use
$scope.votecheck = function(item,emailid){
var email = emailid;
if( typeof item !== 'undefined')
{
var jsonData = $.ajax({
type: "GET",
url: 'ajax/voters.php?id='+item.ID+'&email='+email,
dataType: 'text',
async: false
}).responseText;
if(jsonData === "CanVote"){
return true;
}
else{
return false;
} //return "canvote";
}
}
Use a promise something like this...
Then call something like this...