服务器收不到post数据,为什么?我的代码有问题,谢谢
// post data
let parameters : [String: AnyObject] = [
"uuid" : "731DCD02-1E54-4D28-94F3-D47B7A9D62F4",
"sid" : "b172f2697e717d14134d43f477761382",
]
//init request
self.request = Alamofire.request(
"POST",
"http://test.cnjob.com/test/index/test",
parameters: parameters,
encoding:ParameterEncoding.JSON)
//response
self.request?.responseString { (request, response, body, error) in{
println("---\nrequest--------------------------------->" +
"\n\n\(request)\nresponse------------------------->" +
"\n\n\(response)\nbody---------------------------->" +
"\n\n\(body)\nerror------------------------------->" +
"\n\n\(error)")
}
// 服务器代码为
public function test(){
sk_base::load_sys_class('logs')->add(date("ymd").'filesDATA',var_export($_REQUEST,true));
echo json_encode(array('data'=>$_REQUEST));
}
// 结果:(数据为空,为什么?)
回复 - - - - - - - - - - - - - - - - - - - - - - - - - -->
Optional(<NSHTTPURLResponse: 0x7f845bd63cb0> { URL: http://xxx/test/index/test } { status code: 200, headers {
Connection = "Keep-Alive";
"Content-Length" = 22;
"Content-Type" = "text/html; charset=utf-8";
Date = "Thu, 16 Oct 2014 06:23:23 GMT";
"Keep-Alive" = "timeout=5, max=100";
Server = "Apache/2.4.4 (Win64) PHP/5.4.12";
"X-Powered-By" = "PHP/5.4.12";
} })
身体 - - - - - - - - - - - - - - - - - - - - - - - - - ---->
Optional("{**\"data\":[]**}\r\n")
错误 - - - - - - - - - - - - - - - - - - - - - - - - - ----> 无服务器