Note that there are some explanatory texts on larger screens.

plurals
  1. POgetting data from MySQL on jquerymobile only when I refresh the page
    primarykey
    data
    text
    <p>ok so I'm trying to load data and move to another page once I'm clicking on a search button in my index.html</p> <p>this is my search button</p> <pre><code> &lt;a href="results.html" data-role="button" data-icon="search" data-iconpos="notext"&gt;search&lt;/a&gt; </code></pre> <p>and while it's loading I want the page to run this function and get data</p> <pre><code> $(function () { $.getJSON("API.php", { command: "getBusiness", orig_lat: myPos.lat, orig_long: myPos.lon, distance: 0.05 }, function (result) { $("#locations").html(""); for (var i = 0; i &lt; result.length; i++) { $("&lt;a href='business.html?ID=" + result[i].id + "&amp;bsnName=" + "'&gt; &lt;div&gt;" + result[i].bsnName + " " + (parseInt(result[i].distance * 1000)) "&lt;/div&gt;&lt;/a&gt;").appendTo("#locations");}});}); </code></pre> <p>The page is loading without the DB only when I hit refresh it's showing me the result</p> <p>I'm not sure what's wrong here, should I not use getJSON?? I have seen people talking about .Ajax() is it the same as getJSON() ?</p> <p>is there a better idea on how to move to another page and simultaneously grab data from DB to the page your going to load on jquerymobile?</p> <p>I tried to use the same function using onclick it worked when I gave it a div</p> <p>the rest of the head</p> <pre><code> &lt;link rel="stylesheet" href="styles/jquery.mobile.structure-1.1.0.min.css" /&gt; &lt;link rel="stylesheet" href="styles/jquery.mobile.theme-1.1.0.min.css" /&gt; &lt;link rel="stylesheet" href="styles/my.css" /&gt; &lt;script src="scripts/jquery-1.7.2.min.js"&gt;&lt;/script&gt; &lt;script src="scripts/jquery.mobile-1.1.0.min.js"&gt;&lt;/script&gt; &lt;script src="scripts/cordova-1.8.1.js"&gt;&lt;/script&gt; &lt;script&gt; // Wait for Cordova to load // document.addEventListener("deviceready", onDeviceReady, false); var watchID = null; var myPos = { lat: 32.0791, lon: 34.8156 }; // Cordova is ready // function onDeviceReady() { // Throw an error if no update is received every 30 seconds var options = { timeout: 10000 }; watchID = navigator.geolocation.watchPosition(onSuccess, onError, options); } // onSuccess Geolocation // function onSuccess(position) { var element = document.getElementById('geolocation'); //myPos.lat=position.coords.latitude; //myPos.lon=position.coords.longitude; element.innerHTML = 'Latitude: ' + position.coords.latitude + '&lt;br /&gt;' + 'Longitude: ' + position.coords.longitude + '&lt;br /&gt;' + '&lt;hr /&gt;' + element.innerHTML; } // onError Callback receives a PositionError object // function onError(error) { alert('code: ' + error.code + '\n' + 'message: ' + error.message + '\n'); } </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.
    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