I am trying to send form data in json format to php for process with sql but somehow it's not working, I am bit confuse with ajax and json thing, and very sure not doing right syntax, please help
function testObj(){
var obj = {"firstkey":"firstvalue","secondkey":"secondvalue"};
$.ajax({ type: 'POST', url: 'testPht.php', data: {json: obj},
dataType: 'json' });
}
<form id="theForm" enctype="multipart/form-data">
<select id="itemsList" name="select_pro" onchange="testObj()" >
<option>SELECT PRODUCT</option>
<option value="21">KEY CHAIN</option>
<option value="22">BISCUITS</option>
</select>
<input value="submit" type="submit"></form>
<?php
$json = json_decode($_POST['json']);
var_dump($json);