Ich habe eine PHP-Funktion:PHP-Äquivalent von 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);
Und ich rufe diese Funktion verwenden Javascript Ajax-Aufruf:
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));
Anstatt nun den Aufruf der saveSnapshot Funktion in PHP-Datei Mit JavaScript Ajax möchte ich die saveSnapshot-Funktion aus einer anderen PHP-Datei aufrufen.
Wie mache ich das? Wie mache ich den Anruf? Wie gebe ich die Parameter weiter?
Sie einen Blick auf PHP 'cURL' nehmen kann - http://codular.com/curl-with-php – Diego
Es gibt ein paar Möglichkeiten gibt, aber ich ziehe cURL als die einfachste Methode. – richbai90
@Die können Sie etwas Code diesbezüglich schreiben? – user5155835