DasBoot
DasBoot

Reputation: 707

UIWebView returns blank when dealing with ajax polling website

Everytime i click on my tab it is supposed to send a request with the following method

[self loadingProgress];
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.happy.com/ajax/index.php"]]];

but for some reaso it returns a blank page to me everytime, i was wondering what is a good way to secure a return, does the problem have something to do with my ajax code? i am long polling every 2 seconds.

Upvotes: 0

Views: 315

Answers (2)

Eric Stallcup
Eric Stallcup

Reputation: 389

Michael is correct in that because you're long polling and submitting multiple requests at two second intervals, your UIWebView is attempting to load each new one before the old one completes.

One approach could be to use UIWebView's loading property, which will return a BOOL indicating whether or not it's still processing an NSUrlRequest before you attempt to pass it another. I would also consult the UIWebView Class Reference documentation for additional consideration.

Upvotes: 1

Michael Kessler
Michael Kessler

Reputation: 14235

If the code that you have posted is executed every 2 seconds then this is the problem.
You load a new request before the previous one is completed.

Upvotes: 1

Related Questions