mschwartz / SilkJS

V8 Based JavaScript Swiss Army Knife (and HTTP Server!)
https://github.com/decafjs/decaf
Other
323 stars 37 forks source link

Allow for JSONP style requests #16

Open moduscreate opened 12 years ago

moduscreate commented 12 years ago

Json.success is somewhat limited, as in it only allows requests for direct ajax requests not JSONP.

moduscreate commented 12 years ago

A quick workaround is have your action do something like:

exports = function() { var url = req.data.url, data = doCurlRequest(url);

var response = Json.encode({ data : data });
if (req.data.callback) {
    response = req.data.callback + '(' + response + ')';
}

return response; };

Have that action called via a jst

<%= getMp3File() %>

mschwartz commented 12 years ago

Yikes.

The Json.success(), etc., methods should have that logic in them. An oversight on my part.