I want to put my two functions into one.
They look like this now:
function MeYouFriend(){
$.ajax({
type: "POST",
url: "misc/AddFriend.php",
data: {
mode: 'ajax',
friend: 'ignore',
uID : $('#uID').val(),
fID : $('#fID').val()
},
success: function(msg){
$('#friendsPop').jGrowl('close');
}
});
}
function MeYouFriendY(){
$.ajax({
type: "POST",
url: "misc/AddFriend.php",
data: {
mode: 'ajax',
friend: 'confirm',
uID : $('#uID').val(),
fID : $('#fID').val()
},
success: function(msg){
$('#friendsPop').jGrowl('close');
}
});
}
The difference is only friend: ‘confirm’ and friend: ‘ignore’ , how can i put them together to one and make it simple?
Change your call to
Than change the function to accept the parameter.
Alternate Slightly More Compact Version