我有一个php脚本,它可以计算非常长的事情。如何在Javascript POST方法中包含php文件
它从一个js文件中调用,我想从另一个php文件中调用它,除了从js文件调用它。
该文件称为strategy.server.php,它是建立像这样
<?php
include_once("../config.php");
include_once("../class/simulator.class.php");
$simulator = new Simulator();
$SPOT = $_GET["strikePrice"];
$INTEREST = $_GET["interestRate"]/100;
$VOLATILITY = $_GET["volatility"]/100;
$REMAININGDAYS = $_GET["remainingDays"]/365;
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: application/json; charset=utf-8");
if(!empty($_GET['mycase']))
{
switch($_GET['mycase'])
////calculations...
$data['totalMargin'];
echo json_encode($data);
我想我们同一个文件来计算不同参数(在循环中)。
所以我想过使用的包括和张贴,像这样的参数:
$params = "some params...";
$params .= "strikePrice=".$data["strikePrice"].
"&volatility=".$data["volatility"].
"&remainingDays=".$data["remainingDays"].
"&interestRate=".$data["interestRate"].
"&commission="."7".//$data["commission"].
"&profitDays="."7";//$data["profitDays"];
include("server/strategy.server.php?" .$params);
json_decode($data);
echo $data['totalMargin'];
,但它给出了一个错误:
Warning: include(server/strategy.server.php?mycase=1&rangeMin=0&rangeMax=0&strikePrice=1078&volatility=24&remainingDays=51&interestRate=2.5&commission=7&profitDays=7) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\s-maof-vb\PRO\functions_alarms.php on line 86
如果我包括与参数的文件,它加载了(但没有参数..)
您好保罗,感谢您的回复。因为你可以看到问题更基本。该脚本无法首先加载文件! – devmonster 2012-07-10 09:25:00
啊好的,那里的文件是相对于被包含的文件?如果你采用get参数,它是否工作? 'include(server/strategy.server.php);' – 2012-07-10 09:35:02
是的。我正在尝试设置_GET变量befoe,包括如下所示的函数:$ _GET ['mycase'] = 1; – devmonster 2012-07-10 09:52:38