html5 POST fails... why?

Bringing your stacks to the web

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
LeProfBard
Posts: 17
Joined: Thu Mar 26, 2020 8:23 pm

html5 POST fails... why?

Post by LeProfBard » Mon Apr 27, 2020 1:17 am

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);
?>

LeProfBard
Posts: 17
Joined: Thu Mar 26, 2020 8:23 pm

Re: html5 POST fails... why?

Post by LeProfBard » Mon Apr 27, 2020 2:53 am

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

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: html5 POST fails... why?

Post by adventuresofgreg » Wed Jun 23, 2021 10:29 pm

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.

MarBor
Posts: 15
Joined: Fri Sep 18, 2020 2:56 pm

Re: html5 POST fails... why?

Post by MarBor » Fri Jun 25, 2021 12:59 pm

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

Post Reply

Return to “HTML5”