I'm building an API, and I need a little help, to understand how can I parse data from JSON request, here is my code:
<textarea style="width: 100%; height: 300px;" id="request_json">
{
"requestType":"TourListRequest",
"data":{
"ApiKey":"12345",
"ResellerId":"999",
"SupplierId":"999",
"ExternalReference":"12345",
"Timestamp":"2013-12-10T13:30:54.616+10:00",
"Extension":{
"any":{
}
},
"Parameter":{
"Name":{
"0":" "
},
"Value":{
}
}
}
}
</textarea>
<script>
function SubmitAPI() {
var sendInfo = {
JSON : $('#request_json').val(),
URL : $('#supplier_api_endpoint_JSON_Tour_List').val(),
Type : 'JSON Tour List'
};
$('#response_json').html("Calling API...");
$.ajax({
url: 'post_JSON.php',
type: "POST",
data: JSON.stringify(sendInfo), // send the string directly
success: function(response){
var obj = jQuery.parseJSON( response );
$('#response_json').html(response);
$('#response_validation').html( obj.json_valid );
},
error: function(response) {
$('#response_json').html(response);
}
});
}
</script>
So I need to know how to receive "JSON.stringify(sendInfo)" in my php script post_JSON.php
Any idea ?
Thank you in advance,