I've tried using the following script to send field data back to the server using jquery.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/j ... "></script>
<script>
$(document).ready(function(){
$("#submit").click(function(){
var data=$("#loginform").serialize();
$.post("test_post.lc",
data,
function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
return false;
});
});
</script>
</head>
<body>
<form id="loginform">
<input type="text" name="email" id="email" value="" placeholder="email">
<br/><br/>
<input type="password" name="pwd" id="pwd" value="" placeholder="password">
<br/><br/>
<input type="submit" value="Submit" id="submit">
</form>
</body>
</html>
I have also created 2 separate file, 1 in lc and the other in php to retrieve the posted data and return it back
test_post.php
<?php
echo 'POST: ';
foreach ($_POST as $key => $value) {
echo $key . '=' . $value . ',';
}
?>
test_post.lc
<?lc
repeat for each key tKey in $_POST
put tKey & "=" & $_POST[tkey] && comma after tDat
end repeat
put "POST:" && tDat
?>
When I post the request to the php file ("test_post.php"), I'm able to retrieve the fields value back.
But when I post the request to the lc file ("test_post.lc"), I'm not able to retrieve any value.
I've also tried to post the data direct without jquery and both php and lc is able to return the posted data.
Is it a bug for the livecode server or is there any problem on my code ?
Any experts out here please advise.
Livecode server $_POST for jquery problem
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 15
- Joined: Tue Aug 18, 2015 6:48 am
-
- Posts: 15
- Joined: Tue Aug 18, 2015 6:48 am
Re: Livecode server $_POST for jquery problem
Forget to mention that I've also tried the jquery .get method and it is working fine and able to return the submitted data.
Only the jquery post method together with lc server trying to retrieve the $_POST is not working.
Only the jquery post method together with lc server trying to retrieve the $_POST is not working.
Re: Livecode server $_POST for jquery problem
I know there is or was a bug with POST data to LC server. I thought it was supposed have been fixed? What version of LiveCode Server is running on your server?
http://quality.livecode.com/show_bug.cgi?id=9820 might apply. ( http://quality.livecode.com/show_bug.cgi?id=15173 is marked as duplicate.)
It says the fix was effective in version 6.7.6. In bug #15173 it mentions the default version installed on On-Rev servers is 6.6.5 - but in actual fact my hosting on Tio reports version 6.6.2 in use.
http://quality.livecode.com/show_bug.cgi?id=9820 might apply. ( http://quality.livecode.com/show_bug.cgi?id=15173 is marked as duplicate.)
It says the fix was effective in version 6.7.6. In bug #15173 it mentions the default version installed on On-Rev servers is 6.6.5 - but in actual fact my hosting on Tio reports version 6.6.2 in use.
-
- Posts: 15
- Joined: Tue Aug 18, 2015 6:48 am
Re: Livecode server $_POST for jquery problem
Hi Spark,
Yes confirmed it is the bug and that the version in use by on-rev is 6.6.2.
Since I don't have any choice on the version installed in on-rev, managed to get around it by using ajax with additional line
contentType: "application/x-www-form-urlencoded"
Thanks for hi lighting it out.
Yes confirmed it is the bug and that the version in use by on-rev is 6.6.2.
Since I don't have any choice on the version installed in on-rev, managed to get around it by using ajax with additional line
contentType: "application/x-www-form-urlencoded"
Thanks for hi lighting it out.