I don't know, if this is a duplicate question to any post. As I am not able to get the exact answer of my question..
I have a Ajax request, which is sending 'Category' to a php page on a 'api.mysite.com/create.php'
Ajax code is as follows:
$.ajax({
type: "POST",
url: _apiUrl+"create.php",
contentType: 'application/json',
data: JSON.stringify({ Category: Category}),
dataType: 'json',
success: function(data){
$("#myDiv").html(data);
}});
And my PHP Code is like this:
<?php
ini_set('display_errors', 1);
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');
include("includes/db_connection.php");
$Category = json_decode($_POST['Category'], true);
$Category = $Category[0]['Category'];?>
Any help will be much appreciated. Thank You in advance. Best regards,