Livecode server $_POST for jquery problem
Posted: Thu Dec 31, 2015 2:50 pm
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.
<!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.