You need to use event delegation here since your button has been dynamically added to the DOM:
$('body').on('click', '#btnOk', function() {
var url = "http://localhost:65344/Dispatch";
$(location).attr('href', url);
});
This technique will helps you to attach the click event to this newly added button.