On Thu, Aug 26, 2010 at 3:22 PM, franck <franck@lumberjaph.net> wrote:
Hi I think I've found the reason why it doesn't works.
Hi franck, I guess you need add a reason as to why this method is needed. As I said, once it didn't work, I just used get, and that worked well. As far as the server (Dancer) is concerned, an incoming call is either a get/post/delete, etc. The ajax-ness of it is that it has been initiated as an ajax requested, and that is a client side issue. So, I use jQuery to make a call, and that call comes to the server as a get request. So, why is the ajax method needed on the server? What does it do that get can't or won't do?
There is a patch in the "devel" branch. I need to add more tests, if everything works as expected, it will be released really soon.
On Sat, Aug 21, 2010 at 3:23 PM, P Kishor <punk.kish@gmail.com> wrote:
I can't figure out how the ajax method works. In my JavaScript (with jQuery), I have
$.ajax({ beforeSend: function(xhr){ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); }, url: '/model/' + model_id, dataType: "json", success: function(data) {
// do something with } });
and, in my App.pm, I have
ajax '/model/:model_id' => sub { my $result = do something with model_id return to_json($result); }
however, the above doesn't work at all. I get a 404. If I change the ajax method to
get '/model/:model_id' => sub {}
then it works fine. Which brings me to the question -- what is this ajax method supposed to do better than get or post? And, why doesn't it work for me?
--
-- 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 =======================================================================