I have a form that posts to a url which triggers file download. The server is ASP.NET MVC and I write out a CSV file.
What I want to do is have a jQuery/javascript submit the form instead of a form submit button.
For example, I created a link and attached a handler using jQuery to submit the form:
$(function() {
$("#mylink").click(function() {
$("form").submit();
return false;
});
});
I also tried serializing the form and doing an ajax post with same result.
What I get is that the request/response happens as should, but I do not get the file download (save file) dialog. I can verify the response by using fiddler for example.
It's as if the response is happening out of band or something, in a parallel thread if you will, there is no one at the door.
Can someone shed a light? Thanks
UPDATE
For some reason, $("form").submit()
does not work but I can do my validation and pre-processing, then return true, which works.