客户端程序:
$("#szr").click(function(){
$.ajax({
type: "POST",
contentType:"application/json; charset=utf-8",
url:"http://192.168.31.228:807/serviceServer.php/hello",
data:"{}",
dataType:"json",
success:function(result){
alert(result.username);
},
error:function(ms){
alert("异常"+ms.responseText);
}
});
});
服务器端程序:
<?php
$wbServer= new SoapServer(null, array('uri'=>'textphpwebservice','soap_version'=>SOAP_1_2));
$wbServer->addFunction('sayhello');
$wbServer->addFunction('mymin');
$wbServer->addFunction('hello');
$wbServer->handle();
$json_arr = array("username"=>"szr","age"=>11,"job"=>"sad");
$json_obj = json_encode($json_arr);
//echo $json_obj;
function sayhello($name){
return "hello ".$name."you are great!";
}
function mymin($a,$b){
return $a>$b?$b:$a;
}
function hello(){
return $json_obj;
}
exit();
?>
报错:500 (Internal Server Error)
哪位大神知道是怎么回事啊??