私は現在、TrueSample を使用する調査のヘッダーに含めることができ、調査の Web サービス呼び出しを動的に生成して起動する JavaScript に取り組んでいます。Truesample の要件の 1 つは、すべてのページの後に、そのページに費やされた時間と、調査の開始時に生成されたその他の任意の情報が送信されることです。すべてのページの Web サービス呼び出しを自動化しようとしているので、すべての調査で何百もの Web サービスを使用する必要はありません。
私はかなり進んでおり、これをすべて機能させるためのいくつかのクールなトリックを見つけましたが、javascript を使用して Web サービスを起動するのに苦労しています。
これが私がこれまでに持っているものです:
Qualtrics.SurveyEngine.addOnload(function()
{
var pageStart = new Date();
var beginning = pageStart.getTime();
// Necessary Variables
var account-id = parseInt("${e://Field/account-id}");
var passcode = parseInt("${e://Field/passcode}");
var survey-country = parseInt("${e://Field/survey-country}");
var end-client-id = parseInt("${e://Field/end-client-id}");
var page-exposure-duration;
var page-id = parseInt("${e://Field/pageID}");
var platform-id = parseInt("${e://Field/platform-id}");
var respondent-id = parseInt("${e://Field/respondent-id}");
var response-id = parseInt("${e://Field/response-id}");
var source-id = parseInt("${e://Field/source-id}");
var survey-id = parseInt("${e://Field/survey-id}");
var api-version = parseInt("${e://Field/api-version}");
//End Variables
var that = this;
that.hideNextButton();
var para = document.createElement("footnote");
var test = document.getElementById("Buttons");
var node = document.createElement('input');
var next = document.getElementById("NextButton");
node.id = "tsButton";
node.type = "button";
node.name = "tsButton";
node.value = " >> ";
node.onclick = function trueSample(){
var pageEnd = new Date();
var end = pageEnd.getTime();
var time = end - beginning;
window.alert(pageID + ", time spent on page = " + time);
Qualtrics.SurveyEngine.setEmbeddedData("pageID", pageID + 1);
new Ajax.Request('webserviceURL', {
parameters: {
account-id: account-id,
passcode: passcode,
survey-country: surveycountry,
end-client-id: end-client-id,
page-exposure-duration: time,
page-id: page-id,
platform-id: platform-id,
respondent-id: respondent-id,
response-id: response-id,
source-id: source-id,
survey-id: survey-id,
api-version: api-version}
});
that.clickNextButton();
};
para.appendChild(node);
test.insertBefore(para, next);
});
Javascript から Web サービス呼び出しを実行した経験のある人はいますか? もしそうなら、ajax リクエストを完成させて機能させる方法について何かアイデアはありますか? または、これらの呼び出しに使用できる別の (潜在的により良い) メソッドはありますか? これに関する情報が Stack Overflow にあることは理解していますが、特定のユース ケースがどのように適用されるかを理解するのに苦労しています。
また、JQuery を使用したいのですが、バニラの Javascript と Prototype.JS に限定されていることに注意してください。