« Return to Thread: .post
Re: .post
might be that name is reserved, also added a return false in the function submitting the form
use firebug to view results
try:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>jquery post</title>
<script src="http://jquery.com/src/jquery-latest.pack.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
/// *
$("#formTest").submit(function(){
$.post("jquery-ajax-post.php", {
name: $("#myvar").val() });
return false;// stop the form send via normal action
});
});
// ]]>
</script>
</head>
<body>
<div>
<form id="formTest" action="jquery-ajax-post.php" method="post">
Message: <input type="text" name="myvar" id="myvar" value="Hello to you" />
<input type="submit" class="submit" value="jquery post" />
</form>
</div>
</body>
</html>
-=-=-=-
<?php
print_r($_POST);
?>
php
use firebug to view results
try:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>jquery post</title>
<script src="http://jquery.com/src/jquery-latest.pack.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
/// *
$("#formTest").submit(function(){
$.post("jquery-ajax-post.php", {
name: $("#myvar").val() });
return false;// stop the form send via normal action
});
});
// ]]>
</script>
</head>
<body>
<div>
<form id="formTest" action="jquery-ajax-post.php" method="post">
Message: <input type="text" name="myvar" id="myvar" value="Hello to you" />
<input type="submit" class="submit" value="jquery post" />
</form>
</div>
</body>
</html>
-=-=-=-
<?php
print_r($_POST);
?>
php
2008/5/13 arcticsoft <jpratt@...>:
--
I am using the .post ajax method on a form. I use the following jquery code:
$("form#changeinfo").submit(function(){
$.post("ownerdetails.php", {
name: $("#name").val() });
});
So when the form with the id of changeinfo is submitted it posts information
to ownerdetails.php. But when I write my php in ownerdetails.php and try to
get the value of name it doesnt work. my php is simple just to test:
$name = $_POST['name'];
echo $name;
This does nothing even though there is a value in the field. Its as if
nothing is posted to the server. Any ideas?
View this message in context: http://www.nabble.com/.post-tp17213804s27240p17213804.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.
« Return to Thread: .post
| Free Forum Powered by Nabble | Forum Help |