Does Javascript allow download from a server to local file system

Does Javascript allow download from the server to the local
filesystem ?
I ask that because i am trying to initiate a file download through a
link_to_function method which contains an Ajax.Request ... Here it
is :
<%= link_to_function("Ajax Download Pic",
                                "new Ajax.Request('/main/dl_photos/
#{personne.id}?index=1', {});
") %>

The file does download as it is shown in the terminal with a Sending
XXX.jpg and status 200 Ok, but i don't see how to use the resulting
response ... i know i have to use the onComplete function(request) {},
but how can i implement the function to save the file on the desktop ?

Thx.