NSURL *url = [NSURL URLWithString:@"someurl"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:year1 forKey:@"year"];
[request setPostValue:appy_level forKey:@"appy_level"];
[request setPostValue:reasons forKey:@"reasons"];
[request setPostValue:country forKey:@"c开发者_开发技巧ountry"];
[request setPostValue:city forKey:@"city"];
[request setPostValue:sex forKey:@"sex"];
[request setRequestMethod:@"POST"];
[request setValidatesSecureCertificate:NO];
[request setDelegate:self];
[request startAsynchronous];
NSLog(@"response -%@",[request responseString]);
[self dismissModalViewControllerAnimated:YES];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSString *response = [request responseString];
NSLog(@"%@",response);
}
any idea why this code return (null) i mean response is null? and this requestFinised: method isnt working even i write[requestsetDidFinishSelector:@selector(requestFinished)]; method too.I am confuesed right now.
The first NSLog
won't work because you start your request as asynchronous
.
You chould try putting NSLog(@"finished");
in -requestFinished:
to check if page is loading or not. It can be an error in your server file (e.g. php fatal error).
Have you tried this:
NSString *response = [[NSString alloc] initWithData:[request data] encoding:NSUTF8StringEncoding]; NSLog(@"%@", response);
精彩评论