Page 1 of 1

html5 POST fails... why?

Posted: Mon Apr 27, 2020 1:17 am
by LeProfBard
Hi,
THis is driving me nuts, but it's gotta be something simple.... the LC script below works perfectly when triggered in the run mode of the IDE on the desktop..., but when the same simple file is saved as HTML, nothing makes it through to the server. Can someone suggest what is going on?

on mouseUp

put "tStudentName=" & URLencode("Typhoid Mary") into tStudentName

Post tStudentName to URL "http:....php"

end mouseUp

on the server end, I have a PHP file running this code:

<?php
$tStudent = $_REQUEST['tStudentName'];
mail("goodemail@correctaddress", "Test",$tStudent);
?>

Re: html5 POST fails... why?

Posted: Mon Apr 27, 2020 2:53 am
by LeProfBard
Never got the POST version to work, but a version with GET does work:

on mouseUp
put URLencode("Spanish") into tArray["tLang"]
put URLencode("Typhoid Mary") into tArray["tStudentName"]

put "?tLang=" & tArray["tLang"] & "&tStudentName=" & tArray["tStudentName"] into tDataToSend
Get URL ("https://....php" &tDataToSend)
end mouseUp

Two things seem to have made a difference:
1) moving http to https
2) using the GET URL (...) command (with the variable call via "?", of course)

Still would love to know why POST fails here (I would prefer to use it over GET, but I'm up against some deadlines).
L P B

Re: html5 POST fails... why?

Posted: Wed Jun 23, 2021 10:29 pm
by adventuresofgreg
Have you learned anything more about using POST with html5 standalones? I cannot get my POST command to work at all. I tried your GET solution, and can't get that to work either. I'm using https, and the html is being served on the same domain as the app server.

Re: html5 POST fails... why?

Posted: Fri Jun 25, 2021 12:59 pm
by MarBor
Hi LeProfBard and adventuresofgreg,

I had the same problem with the POST command not working with HTML5 standalones.

I reported a workaround that works for me in another thread:

viewtopic.php?f=120&t=34730&p=197208#p197208

It is basically about using the javascript enverinmont the HTML5 app is running in (as far as iI understand).
You insert a javascript post command and run it in your LiveCode app via the do function (https://livecode.fandom.com/wiki/Do), which allows you to execute some javascript code in your App.

So far, this works fine for me.

Hope it helps!

Best,

Martin