To declare a variable in the global scope, you must initialize it before you try setting it in a function, otherwise the declaration is only applicable to the local scope. If you get your scopes wrong then your references will be invalid and you can expose yourself to bigger issues.
In this case, you will be unable to reference the variables value elsewhere in your script as you are intending to do since the variable only exists within your function currently.
Per MDN:
When you declare a variable outside of any function, it is called a
global variable, because it is available to any other code in the
current document. When you declare a variable within a function, it is
called a local variable, because it is available only within that
function.
var source;
$('#headerSubmit').click(function() {
source = $('#header').attr('value');
});