I’ve had a good search and am stumped. It may be a simple answer, but after 80 hours of work so far this week, I just can’t see it…
In my app I pass some variables to a Web Service, which passes back a single structure containing key/value pairs.
$.ajax({
type: "POST",
url: "it_submitcall.php",
data: {callService: "getcall", callid: $("#callNumber").val()},
dataType: "HTML",
success: function(data){
//do stuff here
},
error: function(data){
// unable to communicate with web service stuff here
}
});
The response I get back is
Array
(
[CALLID] => 44497
[CALLERNAME] => Chris
[TEAMID] => 1175
)
How do I access the elements above in javascript? Any pointers would be greatly appreciated…
Many thanks.
On the PHP side use json_encode to turn the Array into JSON e.g:
Then on the JavaScript side use JSON.parse() to get a JavaScript object back – in your case: