我用 Codeigniter 框架构建了一个简单的网站 (www.imlecturer.arkmon.co.uk)。它根据搜索表单显示人员列表。我的 json 搜索请求是index.php/find/findemp
. 搜索字段名称是firstname
和dept
。现在我想使用 AFNetworking 从 iPhone 发送搜索请求,并显示与表格视图相同的列表,我将从中发送请求以获取更多详细信息 (url: /index.php/find/display/23
)。我在 iPhone 中有这段代码:
NSURL *url = [NSURL URLWithString:@"http://www.imlecturer.arkmon.co.uk/index.php/find/findemp"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation;
operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *req, NSHTTPURLResponse *response, id jsonObject) {
...cell.textLabel.text = [tweet objectForKey:@"firstName"];
这显示错误并显示整个数据库
Error Domain=AFNetworkingErrorDomain Code=-1016 "Expected content type {(
"text/json",
"application/json",
"text/javascript"
)}, got text/html"