简体   繁体   English

ASIFormDataRequest NULL响应

[英]ASIFormDataRequest NULL response

i have simply form request in my Obj-c code, which calls a PHP code from my server 我在我的Obj-c代码中仅具有表单请求,该代码从我的服务器调用了PHP代码


ASIFormDataRequest *req = [[ASIHTTPRequest alloc] initWithURL:url];
[req setPostValue:[NSString stringWithFormat:@"%f",slat] forKey:@"mylat"];
[req setPostValue:[NSString stringWithFormat:@"%f",slng] forKey:@"mylng"];
[req start];
NSLog(@"response -",[req responseString]);
[req release];

am not getting the response in the NSLog, but it runs very fine with stringWithContentsOfURL, and i can see the out put in the browser. 在NSLog中没有得到响应,但是它与stringWithContentsOfURL一起运行非常好,我可以在浏览器中看到输出。 even i changed the ASIFormDataRequest to ASIHTTPRequest and added User-Agent, but nothing works out. 甚至我将ASIFormDataRequest更改为ASIHTTPRequest并添加了User-Agent,但没有任何效果。 i checked it in different versions of SDKs also, 3.0, 3.1.2, 4.0, 4.1. 我也在3.0、3.1.2、4.0、4.1的不同版本的SDK中进行了检查。 but no response 但没有回应

I am sure the response from the server is fine, 我确信服务器的响应很好,

one more sad thing is that, the same ASI code runs fine on my office network (AIRTEL Broadband) and not in my home which has a BSNL broadband, hope its not a service provider issue. 更令人难过的是,相同的ASI代码可以在我的办公室网络(AIRTEL Broadband)上正常运行,而不能在拥有BSNL宽带的家中正常运行,希望这不是服务提供商的问题。

Did any one find such an issue.. 有没有人发现这样的问题。

instead of: 代替:

[req start]

Try: 尝试:

[req startSynchronous]

Normally it is fine to manually call -start on an NSOperation object, but in this case, ASIHTTPRequest explicitly provides a -startSynchronous method, so there is probably a good reason to use it. 通常,可以在NSOperation对象上手动调用-start NSOperation ,但是在这种情况下, ASIHTTPRequest显式提供了-startSynchronous方法,因此可能有充分的理由使用它。

Try... 尝试...

ASIFormDataRequest *req = [[ASIHTTPRequest alloc] initWithURL:url];
[req setPostValue:[NSString stringWithFormat:@"%f",slat] forKey:@"mylat"];
[req setPostValue:[NSString stringWithFormat:@"%f",slng] forKey:@"mylng"];

 [req startSynchronous];
  NSError *error = [req error];
  if (!error) {
      NSLog(@"response -",[req responseString]);
  }
[req release];

Finally i got the answer the Proxy is the problem, if you find the same issue, just check with the proxies in your network settings, i don know abt windows, am on MAC so its jus a chekbox to make it happen and the code i hv used ( for safety purpose ) 最后,我得到了代理是问题的答案,如果您发现相同的问题,只需检查网络设置中的代理,我不知道abt窗口,在MAC上,因此它很容易实现,代码我二手车(出于安全目的)

ASIFormDataRequest *req = [[ASIFormDataRequest alloc] initWithURL:url];
[req setDelegate:self];
[req startAsynchronous];
NSError *error = [req error];
if (!error) {
    NSLog(@"response -",[req responseString]);
}
[req release];
[url release];
- (void)requestFinished:(ASIHTTPRequest *)request
{
// Use when fetching text data
NSString *responseString = [request responseString];
NSLog(@"response %d-%@",[responseString length],responseString);
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}

- (void)requestFailed:(ASIHTTPRequest *)request
{
NSError *error = [request error];
NSLog(@"error - %@\n",error);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM