您可以检查此文件 - https://github.com/surveyjs/surveyjs/blob/master/src/dxSurveyService.ts
下面是负责发送结果的代码:
public sendResult(
postId: string,
result: JSON,
onSendResult: (success: boolean, response: any) => void,
clientId: string = null,
isPartialCompleted: boolean = false
) {
var xhr = new XMLHttpRequest();
xhr.open("POST", dxSurveyService.serviceUrl + "/post/");
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
var data = { postId: postId, surveyResult: JSON.stringify(result) };
if (clientId) data["clientId"] = clientId;
if (isPartialCompleted) data["isPartialCompleted"] = true;
var dataStringify: string = JSON.stringify(data);
var self = this;
xhr.onload = xhr.onerror = function() {
if (!onSendResult) return;
onSendResult(xhr.status == 200, xhr.response);
};
xhr.send(dataStringify);
}
所需的参数是 postId 和结果 json。您可以从服务的 MySurveys 页面获取您的 postId(https://surveyjs.io/Service/MySurveys/注意 MySurveys 页面需要授权)。
这是一个 TypeScript 代码,但我确信它可以很容易地转换为 JS。