function follow_or_unfollow(following,follower,action)
{
var dataString = "following=" + following + "&follower=" + follower;
$.ajax({
type: "POST",
url: "network.callaction.php",
data: dataString,
cache: false,
beforeSend: function()
{
if ( action == "following" )
{
$("#following").hide();
$("#loading").html();
}
else if ( action == "follow" )
{
$("#follow").hide();
$("#loading").html();
}
else { }
},
success: function(response)
{
if ( action == "following" )
{
$("#loading").html('');
$("#follow").show();
}
else if ( action == "follow" )
{
$("#loading").html('');
$("#following").show();
}
else { }
}
});
}
在这种情况下,如果 action 是 FOLLOW,那么应该调用不同的 url,如果 action 是 UNFOLLOW,那么应该调用不同的 url。
那么我们可以在 URL 部分使用 if 条件吗?