Tuesday 15 March 2011

jquery - .ajax will not POST, but will GET with no problem -


I am trying to submit a form using jQuery's .jax () function. It seems that it should be very easy, but for some reason I can not find: "Post" to use the type to work correctly: "GET" is not a problem, but in fact " Post "does not post anything to accept my PHP PHP script. When I do a print_r ($ _ POST), I give an empty array that I have tried to use both input type and input "input" on the input of input but it does not seem to change anything

Edit for clarification
If I do this, print_r ($ _ GET) when I use Type: "GET", it prints all the correct data But if I change the ".jax" option to type: "POST" and print_r ($ _ POST) Try it, it shows an empty array, no content.

JS code:

 var dataString = 'reply_text =' + test + '& post_id =' + post_id; $ .ajax ({type: "post", url: "process.fp", data: datestring, cache: incorrect}); return false; 

Form Code:

 & lt; Form action = "" method = "post" & gt; & Lt; Textarea id = "textboxcontent" name = "reply_text" /> & Lt; Input type = "submit" name = "reply_submit" value = "submit comment" /> & Lt; / Form & gt; 

This can work better:

  var text = .. var post_id = ... $ .ajax ({type: 'post', url: 'process.php', data: {reply_text: text, post_id: post_id}});  

No comments:

Post a Comment