Anraiki
Anraiki

Reputation: 796

Ajax is "Getting" not "Posting"

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!';

  ?>

Upvotes: 2

Views: 96

Answers (1)

Andy E
Andy E

Reputation: 344575

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.

Upvotes: 5

Related Questions