doskmc7870 2015-06-27 00:12
浏览 23
已采纳

在Rails中服务PHP

I have a small PHP service that is being called in a JavaScript file by AJAX :

$.ajax({
    type: "GET",
    url: "getDate.php",                 
    dataType:"json",
    data :{
        fromDate:fromDate,
        toDate:toDate
    },
    success: function(data) {
         ......
        }
});

This service contains :

$fromDate = $_GET['fromDate'];
$toDate = $_GET['toDate'];
$fromDate=date_create($fromDate);
$fromdate = date_format($fromDate,"Y-m-d")."T".date_format($fromDate,"H:i:s")."Z";
$fromdate = urlencode($fromdate);
$toDate=date_create($toDate);
$todate = date_format($toDate,"Y-m-d")."T23:00:00Z";
$todate = urlencode($todate);
$url = "http://194.209.53.19:8086/query?db=Bellevue&q=select+*+from+measures+where+time%3E%3D%27".$fromdate."%27+and+time%3C%3D%27".$todate."%27";
$data = file_get_contents($url, false);
echo $data;

I need to use this in my Rails application. I was wondering if I could put the .php file in a Rails folder, and simply call it. Or if there's a way to do a similar service in Rails?

  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 关于selenium网页闪退
      • ¥15 怎么用PYTHON解类似于x = y+zx + cy = x+zy + v的方程
      • ¥300 FLASH AS2.0制作一个类似手机上下滑动一样的效果
      • ¥15 为什么使用openFoam 中的icoFoam计算圆柱扰流时出现浮点数例外(核心已转储)
      • ¥15 51单片机外部中断控制数码管
      • ¥15 创建网页里面的图片显示不出来
      • ¥15 语音控制的编写?(语言-c#)
      • ¥15 matlab输入书上的代码运行错误
      • ¥15 matlab怎么做三维曲面
      • ¥50 sph光滑粒子法能否解决阶跃性的问题