title: jQuery AJAX POST method not working
body: <p>I am trying to execute the AJAX operation. the call is working fine but the problem I am having is that I am getting an empty string as a response. There is no error in the console. all I get is an empty string. Even when I change the dataType to <code>JSON</code>, I still get the same response.</p>
  
  <p><strong>JavaScript Code:</strong></p>
  
  <pre><code>$.ajax({
    url: "data/saveCart.php",
    method: "POST",
    data: {
      cartItem:item
    },
    dataType: "text",
    success: function(data){
      console.log(data);
    }
  });
  </code></pre>
  
  <p><strong>PHP code:</strong></p>
  
  <pre><code>if(isset($_POST['cartItem'])) {
    echo "AJAX successful";
  } else {
    echo "AJAX failed";
  }
  </code></pre>