2011-07-23 55 views
0

如何通過ASIHTTPRequest發佈表單字段數據(姓名,電子郵件,電話號碼,分數)。我正在使用json webservices。如何通過iphone中的ASIHTTPRequest發佈數據

+1

試過ASIHTTPRequest的好書面文件? – Till

+0

感謝回覆我@Till ..我可以使用ASIHTTPRequest而不是NSMutableURLRequest,但它會給出錯誤,如ASIHTTPRequest未聲明。 – Pinku

+0

NSURL * urlString = [NSURL URLWithString:@「http://www.nieuwe-dag.nl/mobile_be/public/?action=saveScore」]; \t ASIHTTPRequest * request = [ASIHTTPRequest requestWithURL:urlString]; – Pinku

回答

1

試試這個,在你的頭類

ASIFormDataRequest * requestASI變量賦值;

在.m文件

-(void)startASIRequest { 

NSString *strUrl = [NSString stringWithFormat:@"http://your url"]; 

NSURL *url = [NSURL URLWithString:strUrl]; 

[self setRequestASI:[ASIFormDataRequest requestWithURL:url]]; 

[requestASI setDelegate:self]; 

[requestASI setRequestMethod:@"POST"]; 

[requestASI setPostValue:@"1" forKey:@"name"]; 

[requestASI setDidFailSelector:@selector(uploadFailed:)]; 

[requestASI setDidFinishSelector:@selector(uploadFinished:)]; 

[requestASI startAsynchronous]; 


    - (void)uploadFinished:(ASIHTTPRequest *)theRequest { 

NSLog(@"registerFinished %@",[theRequest responseString]); 

    } 

    - (void)uploadFailed:(ASIHTTPRequest *)theRequest { 

NSLog(@"registerFailed %@", [theRequest error]); 

}

+0

'%d'在NSString?我認爲你的意思是'%@'。 –

+0

@xcodeDev:謝謝,對不起,只是一個錯字! – Karthikeyan

+0

它會在創建ASIFormDataRequest * requestASI時給出9個錯誤; .h文件 – Pinku