Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON AJAX connection handicap on 3G ( purgeIdleCellConnections: found one to purge conn )
    text
    copied!<p>I build an app that lists a few items, by requesting <strong>JSONP</strong> from my server with <strong>AJAX</strong> *<em>once</em>*, at startup on #site1 . If you tap on the items(DIVs) it will direct you to #sitedetails . On "sitedetails" the basic details and the description of the clicked item will be loaded with AJAX jsonp (it's only text).</p> <p>My jQuery-Mobile PhoneGap App works fine if I try it on my test-device with WIFI, as soon as I use <strong>3G</strong> it kind of kills the connection. Sometimes "sitedetails" takes really long to make a request (2-5sec.) Usually it takes under 1sec since it is just a few kb. Because I set a timeout on the JSONP req. of 5sec it often shows the error message of my function.</p> <p>When these kind of errors happen I navigate back to site1 and tap on an item again and it will work.</p> <p><strong>In XCode it shows this message while having that problem:</strong></p> <pre><code>purgeIdleCellConnections: found one to purge conn = 0x1f078460 purgeIdleCellConnections: found one to purge conn = 0x1e591fd0 purgeIdleCellConnections: found one to purge conn = 0x1e591fd0 </code></pre> <p>Although my <strong>3G</strong> connection is fast and stable. It can't be the server either, on WIFI it responds immediately and displays the description on "sitedetails".</p> <p><strong>Now the weired thing:</strong> I found out that this only happens if I wait too long after I tapped on an Item. I need to navigate back to "site1" and tap on another item as fast as possible and again, and again, and again.... and there will be no connection problems. But since this is unrealistic for the user it won't help me.</p> <p>Now the source code:</p> <pre><code>var itemid; $(document).on('pageinit', '#site1', function(){ var output = $('#items'); $.ajax({ url: 'http://************.com/api/files/json/mydata.php', dataType: 'jsonp', jsonp: 'jsoncallback', timeout: 5000, success: function(data, status){ $.each(data, function(i,item){ var allitems = "&lt;div id='con' data-id="+item.id+"&gt;"+ "&lt;div id='name'&gt;&lt;b&gt;"+item.name+"&lt;/b&gt;&lt;/div&gt;"+ "&lt;div id='date'&gt;&lt;b&gt;"+item.date+"&lt;/b&gt;&lt;/div&gt;"+ "&lt;/div&gt;"; output.append(allitems); }); }, error: function(){ output.text('ERROR - Could not load data.') } }); }); </code></pre> <p><strong>Tap event:</strong></p> <pre><code>$(document).on('tap', '#con', function(event) { itemid = $(this).attr('data-id'); $.mobile.changePage('#sitedetails'); }); </code></pre> <p><strong>The Problem zone:</strong></p> <pre><code>$(document).on('pagebeforeshow', '#sitedetails', function(){ var output = $('#itemdetails'); $.ajax({ url: 'http://************.com/api/files/json/mydatadetails.php?itemid='+itemid, dataType: 'jsonp', jsonp: 'jsoncallback', timeout: 4000, success: function(data, status){ $.each(data, function(i,item){ var itemdetails = "&lt;div id='name'&gt;&lt;b&gt;"+item.name+"&lt;/b&gt;&lt;/div&gt;"+ "&lt;div id='date'&gt;&lt;b&gt;"+item.date+"&lt;/b&gt;&lt;/div&gt;"+ "&lt;div id='date'&gt;&lt;b&gt;"+item.details1+"&lt;/b&gt;&lt;/div&gt;"+ "&lt;div id='date'&gt;&lt;b&gt;"+item.details2+"&lt;/b&gt;&lt;/div&gt;"; output.empty().append(itemdetails); }); }, error: function(){ output.text('ERROR - Could not load data.') } }); }); </code></pre> <p>That's basically it, except the 2 pages which just have a DIV (site1:#items, sitedetails:#itemdetails).</p> <p>I am using XCode 4.6, PhoneGap 2.9, JQuery 1.9, JQM 1.3.1 on iOS 6.1</p> <p><strong>EDIT: I forgot the mydatadetails.php on the server:</strong></p> <pre><code>&lt;?php header('Content-type: application/json'); $server = "*******.com"; $user = "***********"; $pw = "***********"; $db = "***********"; $itemid = $_GET["itemid"]; $connection = mysql_connect($server, $user, $pw) or die ("Could not connect: " . mysql_error()); mysql_select_db($db, $connection); $sql = "SELECT id, name, date, details1, details2 WHERE id='".$itemid."'"; $result = mysql_query($sql) or die ("Query error: " . mysql_error()); $records = array(); while($row = mysql_fetch_assoc($result)) { $records[] = $row; } mysql_close($connection); echo $_GET['jsoncallback'] . '(' . json_encode($records) . ');'; ?&gt; </code></pre> <p>I am thankful for every answer.</p>
 

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