views:

26

answers:

3

Hi all, i have simply form request in my Obj-c code, which calls a PHP code from my server


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. even i changed the ASIFormDataRequest to ASIHTTPRequest and added User-Agent, but nothing works out. i checked it in different versions of SDKs also, 3.0, 3.1.2, 4.0, 4.1. 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.

Did any one find such an issue..

A: 

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];
Jordan
Nikesh K
am using the [req start] only here in office
Nikesh K
I tried it, but its not working.... and now, its is also not working in my office network.. i don know why...
Nikesh K
A: 

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.

Josh Hinman