I am able to post a string to the PHP file but when I try and select an input field within a form to post the value inside it to the PHP file it doesn’t work. Am I selecting the value in the input field correctly?
.js
$.post("js/data.php", {postid: form.postid.value},
function(output){
$("#gotpostid").html(output).show();
}).fail(function(x,y,z){
$("#gotpostid").html(x + "<br />" + y + "<br />" + z)
});
index.php
<div class="post">
<form name="form"><input type="text" name="postid" value="1234" />
</div>
If i simply do {postid: "some text"} it works fine.
Try the following:
and grab the value by doing