I am trying to submit a form using jQuery's .ajax() function. It seems like it should be pretty simple but for some reason I can't get the type: "POST" to work correctly. Using type: "GET" works no problem, but "POST" doesn't seem to actually post anything to my accepting php script. When I do a print_r($_POST) it returns me an empty array. I've tried using both input type "submit" and "button" on the form input but it doesn't seem to change anything. Any ideas why it's not working?
Ps - there are more than 1 forms on this page.
Edit for Clarification
If I do a print_r($_GET) when i use type:"GET", it prints out all the correct data, but if i change the .ajax option to type:"POST" and try to print_r($_POST) it shows a blank array with no content.
Js Code:
var dataString = 'reply_text='+ test + '&post_id=' + post_id ; $.ajax({ type: "POST", url: "process.php", data: dataString, cache: false }); return false;
Form Code:
<form action="" method="post"> <textarea id="textboxcontent" name="reply_text"/> <input type="submit" name="reply_submit" value="submit comment"/> </form>
dataString
variable used in your ajax request come from? – Darin Dimitrov