$.post done callback closure issue
function submitSurvey() {
var
reason = $("input:radio[name='reason']:checked");
var
reasonVal =
reason.val();
var
reasonHelp =
reason.attr('reasonHelp');
var
url = $('#surveyForm').attr('action');
var posting = $.post(
url, {reason:
reasonVal});
posting.done(function(data) {
alert('You selected: ' +
reasonHelp);
});
}
The alert in posting.done doesnt have access to
reasonHelp due to the closure (at least that's what Web Inspector is telling me).
How can I get access to reasonHelp within done (after the posting is done/successful)?