Javascript gotLocationXml - jcobban/Genealogy GitHub Wiki
The function gotLocationXml
handles the AJAX response from invocation of the script /Family/getLocationXml.php
to a search of the database for matching Locations requested by function locationChanged
. It displays a dialog based upon the response.
The response from the server is an XML document such as:
<locations count="1" name="indiana">
<cmd>
SELECT * FROM tblLR WHERE LEFT(`location`, 7)='indiana' ORDER BY SortedLocation, IDLR LIMIT 40
</cmd>
<location idlr="33475">
<idlr>33475</idlr>
<fsplaceid/>
<preposition/>
<location>Indiana, USA</location>
<sortedlocation>Indiana, USA</sortedlocation>
<shortname>Indiana, USA</shortname>
<tag1>0</tag1>
<used>0</used>
<notes/>
<verified>0</verified>
<latitude>0</latitude>
<longitude>0</longitude>
<fsresolved>0</fsresolved>
<veresolved>0</veresolved>
<qstag>0</qstag>
<zoom>14</zoom>
<boundary/>
</location>
</locations>
The attribute name
in the root node is the string that was entered by the user into an <input type="text">
that has locationChanged
as its change event handler. Since the response has a single match the value of that input field is replaced by the content of the <location>
tag.
<locations count="5" name="indi">
<cmd>
SELECT * FROM tblLR WHERE LEFT(`location`, 4)='indi' ORDER BY SortedLocation, IDLR LIMIT 40
</cmd>
<location idlr="10341">
<idlr>10341</idlr>
<fsplaceid/>
<preposition>in</preposition>
<location>India</location>
...
</location>
....
<location idlr="33475">
<idlr>33475</idlr>
<fsplaceid/>
<preposition/>
<location>Indiana, USA</location>
...
</location>
</locations>
This response has multiple matches so the method prompts the user to choose one.