It appears you've mistyped your type attr: type='POST' should be type: 'POST'
EDIT: on closer look (moreover, inspection in the DevTool of your choice), more appears..
1) start = Date.getTime(); is not going to work for you. Start with assigning a new Date() object to a startDate variable, then assign its getTime() return to your variable start
You should do the same for your end variable value, which by the way you'd preferably define by calling var end, just like you did with start. Not all browsers are strict in respect to this, but it will do wonders for your code/coding consistency.
2) The window unload event listener chunk does not have to be within the document ready listener, which also it seems you overlooked to properly close..
So try this:
var start, end, timeSpent;
$(document).ready( function() {
var dStart = new Date();
start = dStart.getTime();
});
$(window).unload(function() {
var dEnd = new Date();
end = dEnd.getTime();
timeSpent = end - start;
$.ajax({
url: 'timer.php',
type: 'POST',
async: false,
data: {
timeSpent: timeSpent,
x: 'hello'
},
success: function(){
console.log('yay');
}
});
});