javascript - Using ajax to download a file -
i have javascript file uses ajax , passes array of ids rails controller action. controller maps these model objects , generates file containing of data. problem lies in downloading file.
before, saving needed objects in database first, , controller format .ics, call same action, file downloaded.
now more dynamic, , i'm having trouble rendering file have pass in params. there way this? i've tried
render :layout => false, :text => @calendar.to_ical
and
send_data @calendar.to_ical, :type=> 'text/ics'
and
render :text => @calendar.to_ical
all of complete successfully, no file ever downloaded.
any appreciated! thank you!
the short answer cannot use ajax download files (for security reasons). check out this question other options, setting window.location=
or using jquery file download plugin.
Comments
Post a Comment