Note that there are some explanatory texts on larger screens.

plurals
  1. POUser interaction sometimes screws up jQuery ajax requests in UIWebView
    primarykey
    data
    text
    <p>I'm building an iPhone app that displays a UIWebView pointing to a web application I've created.</p> <p>The web application makes frequent web service calls for data items which are used to animate controls on a canvas. The calls for data use jQuery ajax, passing parameters via JSON and receiving an XML response.</p> <p>I'm finding that while user interactions with the UIWebView are occurring, the javascript setTimeout method is blocked and doesn't seem to execute at all. Fair enough; there are ways around this.</p> <p>But the major problem is that every now and then after user interactions (zooming, panning etc), the ajax web service calls will just fail all the time and I can't establish a reason why. Even if they are made repeatedly, for the next few minutes none of them will even get through to the web service. If you completely leave the UIWebView alone, they will never fail as long as the web service is up and connectivity is present.</p> <p>Can anyone suggest why, and how to fix/work around this?</p> <p>Quick update: according to the Safari mobile debugger, the 'response' object in the error function is undefined. (It works if, for example, I make the URL invalid. This can then be called from objective-c by [webView stringByEvaluatingJavascript:@"lastError"], but throws an exception for this 'touched the uiwebview' error):</p> <pre><code> $.ajax({ type: "POST", url: "WebService.asmx/GetValues", async: true, data: "{'pageVersionIndex': " + PageVersionIndex + " , 'timeStreamIndex': '" + TimeStream + "'}", contentType: "application/json; charset=utf-8", dataType: "xml", success: function (response) { UpdateControls(response); }, error: function (response, status, errorthrown) { calling = false; lastError = response.statusText; //Throws exception connectionInterrupted = true; DataRoutine = window.setTimeout(DataService, dataFrequency); } }); </code></pre>
    singulars
    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