Download dynamically generated content using jquery
<p>I have an application in turbogears that dynamically generates an excel spreadsheet, meaning it is not saved as a file in the server, I set the content type and other headers, so it works fine, my question is if it is possible to trigger a download using jquery. Here is what it looks like:</p>

<pre><code>def get_xl(self, **search):
    response.headers['Content-type'] = "application/ms-excel"
    response.headers['Content-Disposition'] = "attachment;filename=myfile.xls"
    book = Workbook()
    ... code that puts stuff in rows ...
    return book.biff_data()
</code></pre>

<p>This returns the data so when I go to the url on my browser, it triggers the download, however, I need to post some data,and it would be nice if everything can be handled with jquery. This is what I have so far on jquery side, I know is all wrong though:</p>

<pre><code>var fields = $('#search-form').serializeObject();
    if ( !fields.length ) {
        alert("Dude, you must search for something.");
        return false;
    }
$.get('/get_xl',fields.data);
</code></pre>
