You can make the Dancer route return whatever you want, be it JSON, HTML or anything else. Normally one uses the "template" keyword to return a full HTML page, but you could return anything else and can also set the various headers accordingly. You might like to have a look at Dancer(2)::Plugin::Ajax, which should make some of that a bit simpler.