Jquery 从Sinatra返回JSONP

Jquery 从Sinatra返回JSONP,jquery,ruby,ajax,json,sinatra,Jquery,Ruby,Ajax,Json,Sinatra,我已经使用返回JSON数据的Sinatra创建了一个web服务 为了让它返回JSON数据,我使用了: class FooRunner def self.run! rates = { "data1" => price_money[2], "data2" => price_money[1], "data3" => price_money[3], "data

我已经使用返回JSON数据的Sinatra创建了一个web服务

为了让它返回JSON数据,我使用了:

class FooRunner
    def self.run!
        rates = {
             "data1" => price_money[2],
             "data2" => price_money[1],
             "data3" => price_money[3],
             "data4" => price_money[6],
             "data5" => price_money[5],
             "data6" => price_money[4]
        }
        rates.to_json
    end
end
然后如下所示:

get '/'  do
  result = FooRunner.run!

  File.open('output.json','w') do |f| #just to keep a record
    f.write result
  end

  response['Access-Control-Allow-Origin'] = '*'
  content_type :json
  result
end
现在,它可以与$.ajax或简单的$.getJSON函数完美结合。然而,我遇到了IE8的一个障碍,在IE8中,需求是JSONP数据

我确实试过:

$.ajax({ 
   url : 'url-of-sinatra-service',
   dataType : 'jsonp'
}).success( function(data){
   //some function
});
显然,这只返回JSON格式的数据,因此我无法真正继续使用该功能。 有没有一种方法可以让我返回JSONP,或者是否可以将其转换为JSONP响应

特别看一看。