NodeJS返回JSONP不使用快递

我试图调用我的nodejs服务器,并显示来自angularjs应用程序的结果。 一直以来的例子,但是当我改变我的代码的示例代码,它总是调用错误callback。 我感觉我的服务器出了问题,但是我不能使它工作,没有快速或其他库的nodejs,以及所有其他答案都使用express。 我怎样才能让它工作,而不使用快递?

在angularjs中的代码,我称之为服务器:

app.controller('Main', function ($scope, $http) { $scope.init = function() { //var api = 'http://api.trakt.tv/calendar/premieres.json/7c989229f2fa626832e7576eb59820e9/20131103/30/?callback=JSON_CALLBACK'; $http.jsonp('http://localhost:8888/selectAllLocations?callback=JSON_CALLBACK').success(function(data) { console.log(data); }).error(function(error) { console.log('My error: ' + error); }); }; }); 

如果我使用var api中的值,结果是好的,成功被调用,而不是我的。

这是我的nodejs服务器中的代码。

 var result = sequelize.query(query, null, options, parameters) .success(function (rows) { if (type == 'select') { response.writeHead(200, { "Content-Type": "application/json" }); response.write(JSON.stringify(rows)); response.end(); } else if (type == 'modify') { response.writeHead(200, { "Content-Type": "text/html" }); response.write("Query was successful"); response.end(); } } ).error(function (e) { console.log("An error occured: ", e); response.writeHead(404, { "Content-Type": "text/html" }); response.write("There was an error man, shits on fire yo ---> " + e); response.end(); } ); 

林相当肯定,我必须包装的JSON结果在一个函数,但我不知道如何,我甚至不知道函数名称,因为这是我得到的所有我的服务器:

path:/ selectAllLocations params:{“callback”:“angular.callbacks._0”}

我明白即时通讯返回纯JSON,我可以看到它在我的回应铬,所以,有一些阻止它调用成功函数。 有人能指出我正确的方向吗?

函数名称被指定为callback参数。

  response.write(params.callback + '(' + JSON.stringify(rows) + ')');