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];