我要發佈按鈕點擊動作代碼通過JSON webservicesmy數據是:後的數據通過JSON web服務在iphone
-(IBAction)login:(id)sender {
NSString *newurlString = [NSString StringWithFormat:@"{\"name\":\"asit\",\"email\":\"[email protected]\",\"businessType\":\"1\",\"score\":30}"];
NSString * url = @"http://www.nieuwe-dag.nl/mobile_be/public/?action=saveScore";
NSData *postData = [newurlString dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSLog(@"urlString::%@",newurlString);
NSLog(@"postLength::%@",postLength);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:300];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection *theConnection =[[NSURLConnection alloc] initWithRequest:request delegate:self];
if(theConnection) {
webData = [[NSMutableData data] retain];
}
else {
NSLog(@"theConnection is NULL");
}
}
並在控制檯上的反應是:
[會話的開始2011-07-25 12:36:48 +0530。] 2011-07-25 12:36:48.860 DepartmentalStoreAdmin [2490:207]無法加載 「header.png」標識符 「com.easternenterpr ise.dag「2011-07-25 12:36:48.864 DepartmentalStoreAdmin [2490:207]無法加載標籤爲 」com.easternenterprise.dag「2011的叢中的筆尖引用的」leher.png「圖片 -07-25 12:36:50.708 DepartmentalStoreAdmin [2490:207] urlString :: {「name」:「asit」,「email」:「[email protected]」,「businessType」:「1」 ,「分數」:30} 2011-07-25 12:36:50.709 DepartmentalStoreAdmin [2490:207] postLength :: 88 2011-07-25 12:36:52.376 DepartmentalStoreAdmin [2490:207] DONE。接收字節:52 2011-07-25 12:36:52.377 DepartmentalStoreAdmin [2490:207]
THEXML { 「結果」: 「ERROR」, 「錯誤」:[ 「名稱不能爲空」]}
我不知道爲什麼它不是發佈。請任何人幫助我,非常緊迫。
在此先感謝: