嗨,我是Ios的初学者,在我的项目中,有用户设施" ForGotPassword"请求
为此,我写了一些代码但是没有用
即objectFromJSONString响应显示为 - >消息:"未找到与请求URI匹配的HTTP资源"我的网址。"
我做错了什么,是我的问题还是服务器端问题?请帮帮我
- (IBAction)submitBtnClicked:(id)sender {
NSLog(@"password ---->>> %@",self.MedicalIdTxt.text);
NSString *urlStr = [NSString stringWithFormat:@"my url"];
NSLog(@"urlStr --->>> %@",urlStr);
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:urlStr]];
[request setRequestMethod:@"POST"];
[request setPostValue:self.MedicalIdTxt.text forKey:@"MedicaidId"];
[request setDelegate:self];
[request startAsynchronous];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
}
- (void)requestFinished:(ASIHTTPRequest *)request {
NSLog(@"requestFinished");
[MBProgressHUD hideHUDForView:self.view animated:YES];
NSLog(@"%@",request);
NSString *receivedString = [request responseString];
NSLog(@"receivedString %@",receivedString);
NSDictionary * jsonObj=[[NSDictionary alloc]init];
jsonObj = [receivedString objectFromJSONString];
NSLog(@"jsonObj result is%@",jsonObj);
NSString *messageStr = [jsonObj objectForKey:@"message"];
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"" message:messageStr delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alertView show];
}
- (void)requestFailed:(ASIHTTPRequest *)request {
[MBProgressHUD hideHUDForView:self.view animated:YES];
NSString *receivedString = [request responseString];
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:receivedString message:@"" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
这里" jsonObj"没有显示来自服务的回应我在这里做错了什么?
答案 0 :(得分:0)
ASIHTTPRequest
因为这么久没有进行维护,所以请改用AFNetworking:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager POST:@"your url"
parameters:@{@"color": @"green"}
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];