Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138249

Why is ajax 'post' not functioning?

$
0
0

I want to send data post to php site then print. The php print is not working. I already examined the other questions but nothing helpful. It will not work out. Why?

JS (working)

$.ajax({
  url: 'https://whatever.com/data.php',
  type: 'POST',
  dataType: 'json',
  contentType: 'application/json',
  async: false,
  data: data
});

PHP backend (not working)

<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST,GET,OPTIONS');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Content-type: application/json;charset=utf-8');
$json = file_get_contents('php://input');
$data = json_decode($json);
print_r($data); ?>

Viewing all articles
Browse latest Browse all 138249

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>