Note that there are some explanatory texts on larger screens.

plurals
  1. PONested getJson() & PHP PDO
    primarykey
    data
    text
    <p>I have looked at other questions and answers regarding this, but can't seem to wrap my head around it...</p> <p>I have a javascript function:</p> <pre><code>function getStates(theDiv){ var stateGroupData; var stateData; var theGHtml = ""; var theHtml = "&lt;h4&gt;MyPage&lt;/h4&gt;"; theHtml = theHtml+"&lt;h5&gt;select a state...&lt;/h5&gt;"; $.getJSON("getStateGroups.php", function(data) { stateGroupData = data; theHtml = theHtml+"&lt;ul&gt;"; $.each(stateGroupData, function(i,jsonData) { theHtml = theHtml+"&lt;li&gt;&lt;a href='#"+jsonData.groupName+"'&gt;"+jsonData.groupID+"&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;"; var theSQL = "getStates.php?gid="+jsonData.groupName; theGHtml = theGHtml+"&lt;div id='"+jsonData.groupName+"'&gt;"; $.getJSON(theSQL, function(data2) { stateData = data2; $.each(stateData, function(i,jsonData2) { alert(jsonData2.stateName); theGHtml = theGHtml+"&lt;span sname='"+jsonData2.stateName+"' lat='"+jsonData2.centerLat+"' lon='"+jsonData2.centerLon+"' zom='"+jsonData2.zoom+"'&gt;"+jsonData2.stateName+"&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"; }); }); theGHtml = theGHtml+"&lt;/div&gt;"; }); theHtml = theHtml+"&lt;/ul&gt;"; }); theDiv.html = theHtml+theGHtml; } </code></pre> <p>The second (ie. nested) getJson does not return any thing... Both PHP files just use PDO to request data from the SAME table. I run the SQL in each file without any issues, so the SQL seems OK.</p> <p>Is this an sync v. async issue with the calls to getJson?</p>
    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.
    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