Forum Discussion
Exporting Variables into a Google Spreadsheet
If you don't want to use the iFrame method, you can use Jquery pretty easily. I don't like to do post publish surgery so I use a bit of Javascript to jack jquery into the head of the document at runtime. Note that you need to load this well ahead of your AJAX calls. Don't try to load this and your AJAX call in the same trigger.
function add_script(scriptURL,oID) {
var scriptEl = document.createElement("script");
var head=document.getElementsByTagName('head')[0];
scriptEl.type = "text/javascript";
scriptEl.src = scriptURL;
scriptEl.id=oID;
head.appendChild(scriptEl);}
//only want to add these once!
if(document.getElementById('jquery')==null){
add_script("https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js","jquery");
}
In a separate trigger (give it some time after your JQUERY head load):
var player=GetPlayer();
var vStudent=player.GetVar("studentName");
var vSupervisor=player.GetVar("supervisorName");
var vFacility=player.GetVar("facilityName");
var fTarget="https://docs.google.com/a/nara.gov/forms/d/YOURUNIQUEFORMID/formResponse";
function submit_form(){
$.ajax({
url: fTarget,
type: "GET",
data: {"entry.1481580269" :vStudent,"entry.1244291729":vSupervisor,"entry.2088465962":vFacility},
success: function(data) {
//won't return since it's cross domain
}
});
return false;
}
setTimeout(submit_form(), 2000);