Forum Discussion
_anomDiebolt_
7 years agoQrew Elite
If you place an AJAX call within a function your function should (1) take parameters and (2) return a promise.
(1) You should simplify the code you post to the minimal size that demonstrates the same problem or exemplifies the same issue you are asking about. Posting a long clist only generates noise and makes it more unlikely you will get an answer.
(2) Despite the API documentation and old answers in this forum, it is better to not supply the body of a POST as XML. See this sample code which calls API_ImportFromCSV without using an XML body:
This is a general principle for almost all QuickBase APIs (unpublished and published). If the docs or source code you are looking at suggest you should send the POST body as XML:
<qdbapi>
<foo>bar<foo>
<baz>quux</baz>
</qdbapi>
You can in fact just send the body as an object
$.ajax(url, {
action: "API_DoSomething:
foo: "bar",
baz: "quux"
});
function uploadData(<parameters>){Other observations about your code:
return $.ajax({...});
});
uploadData(<parameters>)
.then(function(response) {
//further codehere
});
(1) You should simplify the code you post to the minimal size that demonstrates the same problem or exemplifies the same issue you are asking about. Posting a long clist only generates noise and makes it more unlikely you will get an answer.
(2) Despite the API documentation and old answers in this forum, it is better to not supply the body of a POST as XML. See this sample code which calls API_ImportFromCSV without using an XML body:
$.post(dbidTable,{
act: "API_ImportFromCSV",
records_csv: "foo,bar,baz\n12,3\n4,5,6\n7,8,9",
clist: "6.7.8"
}).then(function(xml) {
console.dirxml(xml);
});
This is a general principle for almost all QuickBase APIs (unpublished and published). If the docs or source code you are looking at suggest you should send the POST body as XML:
<qdbapi>
<foo>bar<foo>
<baz>quux</baz>
</qdbapi>
You can in fact just send the body as an object
$.ajax(url, {
action: "API_DoSomething:
foo: "bar",
baz: "quux"
});