Navin
Navin

Reputation: 646

Ajax request fails when passing parameters

I have picture upload code as given below. The Ajax request doesn't work but if I remove the line

data: { group_page_id: group_page_id }

it works well. What causes the problem?

var completed = function(id,name,responseJSON) {
    $.pnotify_remove_all();
    $.pnotify({
        title: 'Uploaded',
        type: 'success',
        text: "Your profile picture has been changed. Give us a moment to process it and it should be ready."
    });

    $.ajax({
        type: 'GET',
        url: '/home/profile_pic_uploaded',
        data: { group_page_id: group_page_id }
    });

    jQuery(".model.add-profile-pic").dialog("close");
    jQuery(".to-change-pic").attr('src','<%= get_profile_pic_bucket_url %><%= group_page_id %>.jpg');
};

Upvotes: 0

Views: 72

Answers (3)

Mirsa
Mirsa

Reputation: 26

As mentioned by Vinit above, modify the data block as below:

data: { "group_page_id": group_page_id }

Upvotes: 0

Zaib Khan
Zaib Khan

Reputation: 470

you must pass group_page_id or define group_page_id some where in the code. right now in your provided code i cant see group_page_id define or passed to this function.

Upvotes: 0

Vinit Sharma
Vinit Sharma

Reputation: 80

Inside your profile_pic_uploaded function in home, add the string argument named group_page_id. It should get to working.

Upvotes: 1

Related Questions