[Dancer-users] sending an image to an ajax request

P Kishor punk.kish at gmail.com
Sat Nov 6 14:02:43 CET 2010


2010/11/6 Иван Бессарабов <ivan at bessarabov.ru>:
> A small pitfall in send_file is that the files should be in the apps
> public folder. I think this is your problem.


Sadly this is not the pitfall (I think). The images are in

app/
  public/
    images/
      foo/
        a_1.gif
        a_2.gif
        a_n.gif
        b_1.gif
        b_2.gif
        b_n.gif
      bar/
        a_1.gif
        a_2.gif
        a_n.gif
        b_1.gif
        b_2.gif
        b_n.gif

If I get access them directly as in /app/images/foo/b_1.gif or
/app/images/bar/b_3.gif it all works fine. However, I want to instead
query for /app/<foo|bar>/<a|b>/<\d>. Then, if the image exists, just
send it back, else create it and send it back.

My sense is that it is not possible to send an image back as a result
of an ajax query. An ajax query can only return text, json or html
(all different kinds of text, really). I am assuming that send_file()
sends a binary stream back that the browser has no way of handling as
a result of an ajax request.

Am I right or wrong?

>
> 2010/11/5 P Kishor <punk.kish at gmail.com>:
>> On the other hand, if the image does exist, I get a 404 (not found).
>>
>> What is going on here? Any ideas?
>



-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================


More information about the Dancer-users mailing list