Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing HTML Response - iPhone App
    primarykey
    data
    text
    <p>I'm creating an app. I'm sending the login info using HTTP POST method and the replyI'm getting from server is in HTML format. How can I parse that HTML and add different methods for succession or failure? What I'm trying to achieve is, upon login failure it should show the message using UIAlerView and upon successful login, the app should change the view with animation. :) </p> <p>The code I'm using right now:</p> <pre><code>- (IBAction) loginButton: (id) sender { indicator.hidden = NO; [indicator startAnimating]; loginbutton.enabled = NO; // Create the username and password string. // username and password are the username and password to login with NSString *postString = [[NSString alloc] initWithFormat:@"username=%@&amp;password=%@",userName, password]; // Package the string in an NSData object NSData *requestData = [postString dataUsingEncoding:NSASCIIStringEncoding]; // Create the URL request NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString:@"http://localhost/dologin.php"]]; // create the URL request [request setHTTPMethod: @"POST"]; // you're sending POST data [request setHTTPBody: requestData]; // apply the post data to be sent // Call the URL NSURLResponse *response; // holds the response from the server NSError *error; // holds any errors NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse:&amp;response error:&amp;error]; // call the URL /* If the response from the server is a web page, dataReturned will hold the string of the HTML returned. */ NSString *dataReturned = [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding]; alertWithOkButton = [[UIAlertView alloc] initWithTitle:@"Status..." message:[NSString stringWithFormat:@"%@",dataReturned] delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil]; [alertWithOkButton show]; [alertWithOkButton release]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload