0
我有兩個按鈕,Save和Unsave。通常,我每個人都去一個PHP的帖子頁面,並刷新頁面。如果您點擊保存,頁面將被刷新,只有Unsave會顯示 - 反之亦然。使用jQuery和Ajax切換按鈕
我試圖用Ajax和jQuery來做到這一點。基本上,我有這些:
下面是通常會切換他們PHP:
//$thisIsSaved would return 1 if the coupon has been saved and 0 if not
$hasSaved = "inline";
$youveSaved = "none";
if($thisIsSaved > 0 && $_SESSION["loggedIn"] == 1)
{
$hasSaved = "none";
$youveSaved = "";
}
elseif($thisIsSaved == 0 && $_SESSION["loggedIn"] == 1)
{
$hasSaved = "";
$youveSaved = "none";
}
else
{
$hasSaved = "none";
$youveSaved = "none";
}
我怎麼能這樣做不需要刷新頁面,用純阿賈克斯+ jQuery的?