First off all, when you declare a local variable in a function, use "var" scope. This will prevent problem in the future when your app gets bigger and somewhere you use the same variable names.
Now, let's talk about the jQuery.
1. Why you use .get() method? It is critical that you know what you are doing since this problem is very similar to the one that you had before.
2. .datepicker('setDate', data.MyDate); -- Where does .MyDate refer to?
3. It would be wise that you make sure your document is ready before allowing user clicking something.