July 26, 201115 yr Hey, Made a similar thread a couple of days ago, but I wasnt sure what was going on. Pretty simple question if anyone can help. Using jQuery's post method, I would like to send some data to a php page, which returns a variable which gets printed back out, obviously without the page refreshing. No real purpose, but if I know how this works I can start to play with it. So here we go: <form class="myform"> <input type="hidden" name="hiddenform" value="some value here" /> <input type="submit" value="submit" /> </form> So when that submit button is clicked, it runs this: $.post("test.php", $(".myform").serialize()); Okay, now on my test.php page: <? $thevalue = $_POST['hiddenform']; ?> Now the problem i'm having, is how do I get that variable to appear back on the page with the form? So I can say echo $thevalue; I assume that there needs to be more to the jquery, but the jQuery API isnt so amazing for me. Cheers
July 26, 201115 yr jquery post: $.post("test.php", $(".myform").serialize(),function(data){ alert(data); }); php file: $thevalue = $_POST['hiddenform']; return $thevalue; that should alert the return value from your php file obviously you can then use the data variable in any way you like it's just an example. Edited July 26, 201115 yr by ysuran
Create an account or sign in to comment