我的迴應顯示爲空。但是當你在瀏覽器中輸入網址時,它會顯示1.但是在我的代碼中,它返回0. 網址是http://boomagift.ramansingla.com/[email protected]。如果有人能幫助我,我會很感激。我是iOS新手。迴應爲空
+(NSDictionary *)forgotpassword:(NSString *)email
{
NSDictionary *dict=[[NSDictionary alloc]init];
NSString *urlStr=[NSString stringWithFormat:@"http://boomagift.ramansingla.com/forgotpassword.php?email=%@",email];
NSLog(@"%@",urlStr);
NSMutableURLRequest *request=[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlStr]];
dict = [self sendRequest:request];
NSLog(@"%@",dict);
return dict;
}
+(NSDictionary *)sendRequest:(NSMutableURLRequest *)request
{
NSHTTPURLResponse *response;
NSError *error;
NSData *responseData;
responseData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if(responseData&&[responseData length])
{
NSDictionary *dictionary=[NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error];
return dictionary;
}
else
{
UIAlertView *noInternetAlert=[[UIAlertView alloc] initWithTitle:@"Boom A GIft" message:@"Server Error" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[noInternetAlert show];
noInternetAlert=nil;
return nil;
}
}
如果我在瀏覽器中運行這個URL我得到了答案** 1 **,它是正確的或你得到的迴應是別的 –
是的即時獲得響應是null在我的代碼和瀏覽器中顯示1 – user3651677
在瀏覽器中它是0請檢查 – aBilal17