I am new to web services.I have the following code and when I try to run it on the local host I am not geting the required output...it shows FirstName:undefined LastName:undefined..
following is my code
$(document).ready(function(){
var employees = [
{ "firstName":"John" , "lastName":"Doe" }
];
$.ajax({
url: "MyService.php",
type: "POST",
data: employees,
dataType: "json",
success:function(data) {
alert("Firstname:"+data.firstName+", LastName: "+data.lastName);
},
error:function(data) {
alert('error');
} });
});
The php code is
echo json_encode($_POST);