Parsing a returned API_DoQuery withing html page.

  • 0
  • 1
  • Question
  • Updated 6 years ago
  • Answered
I get and xml object back, but can't parse it etc........The GetElementByID doesn't think it's an XML file. I tried using the .responsexml also. It has the values I'm looking for, but parsing doesn't work.

<script language="javascript" type="text/javascript">
function GetData() { alert("Getdata"); var xmlHttp = null; var qdbURL; qdbURL = "https://octo.quickbase.com/db/bhvpfcgtf?a=API_DoQuery&query={6.EX.'"; qdbURL += document.getElementById('username').value; qdbURL += "'};"; alert(qdbURL); xmlHttp = new XMLHttpRequest(); xmlHttp.open("GET", qdbURL, false); xmlHttp.send(); var xmlDoc = xmlHttp.response; alert(xmlDoc); alert(xmlDoc.getElementsByTagName("update_id").value); alert("done!"); }</script>
Photo of David W. Brown

David W. Brown

  • 0 Points

Posted 6 years ago

  • 0
  • 1
Photo of Trinity_QB_Ninja

Trinity_QB_Ninja, Champion

  • 40 Points
I would suggest using the QuickBase Javascript SDK

https://github.com/QuickbaseAdmirer/Quickbase-JavaScript-SDK

Or better yet jQuery to do this.

The QuickBase SDK has methods for parsing the returned XML response.

With jQuery it is very simple:

Lets say you want to loop over the records that were returned:

$.each($("records", xmlDoc), function(){
var fid3 = $("f[id=3]", this).text();
......
});

With jQuery you would use $.ajax for the XML request. jQuery handles the best method for getting the data. There are also additional parameters that can be set to prevent caching and asynchronous calls.