I am new to JSON, and I am trying to get the JSON response and then parse it in jquery.
Here is my sample code,
$.ajax({
type: "GET",
url: 'ajax-script.php',
data: {
TERMINAL_CODE: value
},
success: function(data) {
$('#arrivals').html(data.Success);
//alert(data.length);
}
});
ajax-script.php
$code = $_GET['TERMINAL_CODE'];
$jsonData = '{"Success" : true ,"Response": [{
"TERMINAL_CODE": 16,
"TERMINAL_NAME": "FAISALABAD"
}, {
"TERMINAL_CODE": 17,
"TERMINAL_NAME": "JHANG"
}, {
"TERMINAL_CODE": 1,
"TERMINAL_NAME": "LAHORE"
}, {
"TERMINAL_CODE": 5,
"TERMINAL_NAME": "MULTAN"
}, {
"TERMINAL_CODE": 23,
"TERMINAL_NAME": "NOWSHERA"
}, {
"TERMINAL_CODE": 25,
"TERMINAL_NAME": "PESHAWAR"
}, {
"TERMINAL_CODE": 22,
"TERMINAL_NAME": "RAWALPINDI"
}, {
"TERMINAL_CODE": 31,
"TERMINAL_NAME": "SIALKOT"
}]
}
';
echo $jsonData;
This code gives me the complete array in arrivals div, But i need TERMINAL_CODE and TERMINAL_NAME separately?
How can I achieve this?