- This topic has 17 replies, 4 voices, and was last updated 2 years, 9 months ago by
Yuri Kovelenov.
-
AuthorPosts
-
2019-11-28 at 11:57 pm #21492
chaac
ParticipantI have a question..
i want send data with “Send Data” Puzzle to PHP File. But they dont have any request.. no Data sent? The $_POST array was empty..
Where is the mistake.. i don’t knowBut here my simple Test (Result -> int(0)):
2019-11-29 at 6:28 am #21495Yuri Kovelenov
Staff2019-11-29 at 6:42 am #21496chaac
Participantlike this .. no
2019-11-29 at 6:55 am #21498Yuri Kovelenov
Staff2019-11-29 at 7:12 am #21499chaac
Participantyes, localhost:80 (xampp-server)
2019-11-29 at 12:54 pm #21503Yuri Kovelenov
Staff2019-12-02 at 1:59 pm #21577chaac
Participantyes, all in the same folder on Webserver “http://localhost/verge3d/test.php”.
I make a Test .. switch POST to GET:
<?php var_dump(count($_GET)); ?>
Call WB: http://localhost/verge3d/test.php?test=true
Resuld: int(1) It’s running
I also get a feedback about the 3d scene.. only no POST is transmitted.2019-12-02 at 2:49 pm #21589Yuri Kovelenov
StaffI’m no PHP expert, but there might be situations when you cannot read POST contents.
BTW, can you also check if the piece of the JavaScript code behind the send data puzzle (can be seen in the visual_logic.js) works in your setup?2019-12-02 at 9:31 pm #21602chaac
ParticipantIt’s all visible:
this.procedures[“dophp”] = dophp;
..
function dophp(VAR) {
console.log(VAR);
}
..
oActivObj = null;
registerOnClick(aAllEditableObj, function() {
objDict = getObjCustomProps(_pGlob.pickedObject);
if (dictGet(objDict, ‘activ’) == false) {
outline(aAllEditableObj, ‘DISABLE’);
oActivObj = _pGlob.pickedObject;
outline(oActivObj, ‘ENABLE’);
dictSet(objDict, ‘activ’, true);
} else {
outline(oActivObj, ‘DISABLE’);
dictSet(objDict, ‘activ’, false);
oActivObj = null;
}
sendData(objDict, ‘test.php’, function() {
dophp(_pGlob.loadedFile);
});
}, function() {});.. it all works HTML-Elements control 3d-Scene and vice versa.
In the same html run a $.ajax POST (2 Objects to test.php).. it work’s perfectly. Only the “send data” Puzzle .. send NO data.. no String, no Number, no Object .. nothing.2019-12-02 at 11:50 pm #21605chaac
Participantok, i have the solution!!
The function sendData() send the request Header as Content-type ‘application/json’, and strings as ‘text/plain’. Anyway.. the $_POST Array ist always empty!
On PHP we must decode the file content as json.. that’s allif (empty($_POST)) { $_POST = json_decode(file_get_contents("php://input"), true) ? : []; } print_r($_POST);
Result are an full Array!
Maybe should mention that at “send data” in the help.2019-12-03 at 12:15 pm #21614Yuri Kovelenov
Staff2020-09-29 at 8:53 pm #33584cukas
ParticipantI’m trying to send a variable from verge to a php file so then I could make an insert to a data base, but i can’t get any value … I tried to use your last code to decode but no results…
Attachments:
You must be logged in to view attached files.2020-09-30 at 6:07 am #33591Yuri Kovelenov
Staff2020-09-30 at 2:27 pm #33643cukas
ParticipantHi Yuri, there is no errors… the problem is getting the value, because every time I try to access to that data for example using var_dump returns a null space.
…do you have any example to simple get variables values from verge to php ?2020-10-01 at 7:06 pm #33704cukas
ParticipantWow I finally did it, as chaac said this need to be on description cause is hard to get data without knowing the decoder
…also mention that need to echo something and then in the puzzles use loaded data to receive that echo from the php.
awesome ty all -
AuthorPosts
- You must be logged in to reply to this topic.