tags:

views:

51

answers:

1

I am trying to use the Post Method in my jquery code but it using the Get method for some reason. I am working under the Wordpress Framework which have renamed the "$" function to jquery, which I then renamed to $j. Can anyone help me with this simple function?

  $j.ajax({
method: "POST",
url: "extension/marker.php",
data: "series=test",
dataType: "text",
success: function(data){ 
 $j("#text").text(data);
 console.log('success' + data);
 }
});

PHP File:

  <?php 

  if($_POST['series'] == "test")
   echo 'yay!';

  if($_GET['series'] == "test")
   echo 'boo!';

  ?>
+5  A: 

method: "POST" should be type: "POST". See the docs.

type
Default: 'GET'
The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.

Andy E
I always remember it to be "method" too... I suppose I've written too many <form> tags :)
AKX
ahhh! I suppose I overlooked that in the documents :(
Anraiki
@AKX: Yes. IMO, it should have been named `method` to keep consistency with the parameter name of the `XMLHttpRequest.open` method and with the `method` attribute of forms.
Andy E