我有一个PHP函数:相当于PHP的Javascript的XMLHttpRequest的
function saveSnapshot() {
header("Content-Type: application/JSON: charset=UTF-8");
global $CFG;
$resString = "{\"Success\": \"True\"}";
$snapshotName = getArgument("snapshotName");
$user = getArgument("userId");
$ttd = getArgument("ttData");
$fed = getArgument("feData");
$ttData = json_decode($ttd, true);
$feData = json_decode($fed, true);
我打电话使用Javascript Ajax调用这个函数:
xhttp.open("POST", "myfile.php", true); // asynchronous
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("reqType=saveNewSnapshot&newSnapshotName=" + newSnapshotName + "¤tSnapshotName=" + currentSnapshotName +
"&configId=" + currentConfigId + "&ttData=" + JSON.stringify(timeTable) +
"&feData=" + JSON.stringify(fixedEntry));
现在,而不是调用PHP文件saveSnapshot功能使用javascript ajax,我想从其他一些PHP文件调用saveSnapshot函数。
我该怎么做?我该如何拨打电话?我如何传递参数?
你可以去看一下PHP'cURL' - http://codular.com/curl-with-php – Diego
有几种方法,但我更喜欢卷曲作为最简单的方法。 – richbai90
@Diego你可以发表一些关于此的代码吗? – user5155835