Cannot find solution to this simple problem, i just do some voting app, and if users votes I would like to show simple alert like "Thanks" , but I cannot find the way to do it from the controller? I have tried the simple jQuery code like this but it's not working.
echo "<script>alert('You have already voted');</script>";
Any simple solutions?
public function voting()
{
$ip=$_SERVER['REMOTE_ADDR'];
$id = Input::get('msg_id');
$vote = Input::get('vote');
$count = Voting::wheremes_id_fk($id)->whereip_add($ip)->count();
if($count==0)
{
if($vote == "up")
{
Project::whereid($id)->increment('up');
Voting::insert(
array('mes_id_fk' => $id, 'ip_add' => $ip )
);
}
else if ($vote=="down") {
Project::whereid($id)->decrement('down');
Voting::insert(
array('mes_id_fk' => $id, 'ip_add' => $ip )
);
}
}
else {
// How to popup "thanks" alert??
}
}