//POST请求
1 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 2 { 3 // 1.URL 4 NSURL *url = [NSURL URLWithString:@"http://localhost:8080/MJServer/login"]; 5 6 // 2.创建一个请求对象 7 ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; 8 9 // 3.设置请求参数(建议使用setPostValue多一点) 10 [request setPostValue:@"123" forKey:@"username"]; 11 [request setPostValue:@"123" forKey:@"pwd"]; 12 13 // 4.开始请求 14 [request startAsynchronous]; 15 16 // 5.设置监听方法 17 __weak typeof(request) weakRequest = request; 18 [request setCompletionBlock:^{ 19 NSLog(@"请求完毕--%@", [weakRequest responseString]); 20 }]; 21 }
下载