duanjiwang2927
2016-10-15 16:13
浏览 40
已采纳

Javascript调用php标头[重复]

This question already has an answer here:

I have the following javascript code:

function like(){
  if(loged) {
    if(liked) {
      likes-=1;
      liked = false;
      document.getElementById('alike').src = "img/icons/like.png";
    } else if(disliked) {
      dislikes-=1;
      disliked = false;
      likes+=1;
      liked = true;
      document.getElementById('alike').src = "img/icons/like1.png";
      document.getElementById('adislike').src = "img/icons/dislike.png";
    } else {
      likes+=1;
      liked = true;
      document.getElementById('alike').src = "img/icons/like1.png";
    }
  } else {
    <?php header("Location:login");?>
  }
}

I want to redirect the user to the login page how can i user php inside javascript to this. I do not want to have to use any other things like ajax etc. Thanks.

</div>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题