cross domain ajax to dancer app
I am trying to send an ajax GET request from one dancer app (powered by Starman on one port) to another dancer app (powered by Starman on another port). I am using jQuery like so $.ajax({ "url": url, "data": data, "type": "GET", "dataType": "jsonp", "jsonpCallback": function(res) { .. do something with res .. } }); I can see the result come back from the second dancer app in Safari web inspector. It looks like a JSON stream, but it doesn't trigger the jsonpCallback. The web inspector complains that "Resource interpreted as script but transferred with MIME type application/json." I am wondering if there is something in the second dancer app (the one that returns the result) which is setting a wrong header that is causing the callback to not be tripped. The code in the second dancer app looks like so use Dancer::Plugin::REST; prepare_serializer_for_format; use DBI; get '/poly.:format' => sub { my $poly = params->{'BBOX'}; my $res = recs_within_poly($poly); return $res; }; By the way, seems like if I use Dancer::Plugin::REST, I can't use Dancer::Plugin::Ajax, or can I? Changing the above route to `ajax '../ => sub {};` gives an error that the route was not found.
participants (1)
-
Mr. Puneet Kishor