views:

212

answers:

0

Hi, I try posting data to server, which in response i get the length as 0 and data not saving in DB. scenario is when i init the url the data would be sent and send back a response saying "data saved in DB"

NSString *mydata = @"HelloWorld ";

NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];

[request setURL:[NSURL URLWithString:@"http://mypc/testfolder/ProcessPost.aspx"]];

[request setCachePolicy:NSURLRequestUseProtocolCachePolicy];

[request setHTTPMethod: @"POST"];

//[request setTimeoutInterval:10.0];

[request setHTTPBody:[mydata dataUsingEncoding:NSASCIIStringEncoding]];

conn=[[NSURLConnection alloc] initWithRequest:request delegate:self];

if( conn ){
responseData = [[NSMutableData data] retain]; }

else{

NSLog(@"No connection set");

}

(void) connectionDidFinishLoading:(NSURLConnection *)connection{

NSLog(@"connectionDidFinishLoading %i", [responseData length] );

}

I am getting the response data length as 0. I am testing this thru the simulator and wifi. is there any wrong in the code...?

help needed please.

Thanks.