.val(variable) Not setting a value

.val(variable) Not setting a value

    Hi there, 

    I'm fighting with this piece of code. I get result back from a PHP call and data does infact get populated. Alerting out setName show the correct value, but the next line (7) doesn't work. 

    Any ideas?
    1. function(data)
    2.         {
    3.             var images = data;
    4.             var setName = images['set'][0].name;
    5.             alert(setName);
    6.             $('set-name').val(setName);

    7.         });