Does anyone have an example of how to pass values between variables (from Storyline to server) using AJAX?
I need to create a Storyline module to call a user ID, hold the user ID in memory, collect a score, and pass both the user ID and the final score to a SQL database using AJAX.
I've asked this before, but I can no longer find the replies. Thanks for your patience!
I have recently integrated storyline in my ASP.NET MVC5 application. I don't get what do you mean by "hold the user ID in memory" ? If you can post more details about your project, I would love to look into it.
In my application, for passing variables back to my ASP.NET application, I have used async AJAX to post data to my application. Following is the code I have used:
var player = GetPlayer(); var unitId = player.GetVar("UnitId"); var name = "Bjacobs";
var xhr; if (window.XMLHttpRequest) xhr = new XMLHttpRequest(); else xhr = new ActiveXObject("Microsoft.XMLHTTP"); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { var serverResponse = JSON.parse(xhr.responseText); } } var url = '<your URL to post variables>'; xhr.open("POST", url, true); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.send("UnitId="+UnitId+"&name="+name);
2 Replies
Hi B Jacobs,
I have recently integrated storyline in my ASP.NET MVC5 application. I don't get what do you mean by "hold the user ID in memory" ? If you can post more details about your project, I would love to look into it.
In my application, for passing variables back to my ASP.NET application, I have used async AJAX to post data to my application. Following is the code I have used:
Thanks Basit for sharing that here!
This discussion is closed. You can start a new discussion or contact Articulate Support.