iPhone ASIHttpRequest - can't POST variables asynchronously
- by Eamorr
Greetings,
I'm trying to simply POST data to a url using ASIHttpRequest.
Here is my code:
__block ASIHTTPRequest *request=[ASIHTTPRequest requestWithURL:url];
[request setPostBody:[NSMutableData dataWithData:[@"uname=Hello" dataUsingEncoding:NSUTF8StringEncoding]]];
[request setDelegate:self];
[request setCompletionBlock:^{
NSString *response=[request responseString];
UIAlertView *msg=[[UIAlertView alloc] initWithTitle:@"Response" message:response delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[msg show];
[msg release];
}];
[request setFailedBlock:^{
NSError *error =[request error];
}];
[request startAsynchronous];
Basically, my url is xxx.xxx.xxx.xxx/login.php, when I dump the PHP $_POST variable, I just get an empty array - i.e. no POST parameters are sent! The rest of the PHP is tested and working fine.
I've looked through the allseeing-i.com documentation and examples and can't seem to resolve this problem.
Any insight greatly appreciated.
Many thanks in advance,