webview 加載頁面的兩種請求方式: get和post請求php
get請求web
//習慣採用loadRequest方式,你可採用其餘方式iphone
NSURL *url = [[ NSURL alloc] initWithString:@"http://www.********.com.cn:8081/index.php/Account/iphoneTopup?email=a@a.com&password=1&amount=12"]; [WebView loadRequest:[ NSURLRequest requestWithURL: url ]];
post請求post
NSURL *url = [NSURL URLWithString: @"http://www.*******.com/index.php/Account/iphoneTopup"]; NSString *body = [NSString stringWithFormat: @"email=%@&password=%@&amount=%@",@"a@a.com",@"1",@"12"]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url]; [request setHTTPMethod: @"POST"]; [request setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding]]; [WebView loadRequest: request];