Accessing $(this).data('link') in ajax success function inside modal form

Accessing $(this).data('link') in ajax success function inside modal form

Hi there,

How do I get the value of $(this).data('link').id into the success part of my ajax call in a modal form (when validations have been satisfied)? I can retrieve it ok in the form function but I guess the ajax success function can't see it?

$('.extern').click(function(event) {
  event.preventDefault();
  $( "#dialog-form" )
    .data('link', this)
    .dialog( "open" );                                  
  });
});

success: function(msg){
// do something like this, var test = $(this).data('link').id;
  alert(msg);
}

Many thanks,

Chris