views:

34

answers:

3
$.ajax({
    type: "POST",
    url: "misc/AddFriend.php",
    data: {
        mode: 'ajax',
        friend: c,
        uID: $('#uID').val(),
        fID: $('#fID').val(),
        bID: $('#bID').val()
    },
    success: function (msg) {
        alert('OK');
        $('#friend' + fID).slideUp('slow');

    }
});

IS this right? It wont slide up right now

+1  A: 

Well, you can find out the ID by alerting the result of the concatenated expression.

Since you're feeding an anon object you don't have a reference. It's probably easiest if you just invoke .val() again:

    $('#friend' + $('#FID').val() ).slideUp('slow');

Otherwise it's probably doing $('#friendundefined').slideUp.

meder
A: 

The syntax is correct, but whether those ids and the value of variable c make sense in the context of your application is a different story.

I notice that you are using fID in the function to execute when the call succeeds. fID and also c would need to be defined outside of the function - I mean that you can't use the value of property fID of the object assigned to data.

You could create that object outside of the ajax function however and use the property for both data and in the selector in the function to run when the call succeeds.

Russ Cam
+1  A: 

try:

$.ajax({
    type: "POST",
    url: "misc/AddFriend.php",
    data: {
        mode: 'ajax',
        friend: c,
        uID: $('#uID').val(),
        fID: $('#fID').val(),
        bID: $('#bID').val()
    },
    success: function (msg) {
        alert('OK');
        $('#friend' + $('#fID').val()).slideUp('slow');

    }
});
Vaibhav Gupta