Reputation: 53
I built a simple website with Codeigniter framework (www.imlecturer.arkmon.co.uk). It displays list of people according to search form. My json search request is index.php/find/findemp
. Search fields names are firstname
and dept
. Now I want to send search request from iPhone with AFNetworking and display the same list as a table view from which I will send request for more details (url:/index.php/find/display/23
).
I have this code in 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"];
This shows error and displays whole database
Error Domain=AFNetworkingErrorDomain Code=-1016 "Expected content type {(
"text/json",
"application/json",
"text/javascript"
)}, got text/html"
Upvotes: 1
Views: 292
Reputation: 53
Yes, the solution was to either change the receiver in app as Keith Smiley suggested or creating own JSON generator following this and this tutorial.
Upvotes: 1