Download a file using jQuery after creating it in the server

When I click a button on the client side I want to invoke a public static webmethod on the server side using AJAX. The static method will create the appropriate file. After the file is created I need to download it to the client desktop. I’ve found John Culvinar’s jquery filedownload plugin but haven’t been able to implement it so far. I know that using this plugin also requires writing a cookie so that it knows that the download is complete. Where do I put this code in the server side? After creating the file? I’d be very glad if someone could show me a sample on this scenario, maybe on jsfiddle.net