我是网络服务的新手。我有以下代码,当我尝试在本地主机上运行它时,我没有得到所需的输出......它显示FirstName:undefined
LastName:undefined
..
以下是我的代码
$(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');
} });
});
php代码是
echo json_encode($_POST);