Hello,
I've done some research on this, but everything I find doesn't seem to function properly. I'm trying to pass variables collected in twine to PHP so that I can print them as a txt file. I have worked out the PHP stuff, so that's not the issue, but when I try to pass twine variables via AJAX, I get an undefined error.
I'm using Twine v. 2.0.10 with SugarCube 1.0.32.
I'm collecting variables with the following:
Name: <<textbox "$name" "">>
Email: <<textbox "$email" "">>
Under story Javascript I have defined the sendAjax function:
//requires jquery
function sendAjax() {
$.ajax({
type: "POST",
url: "receive-ajax.php" ,
data: { name: state.active.variables.name, email: state.active.variables.email },
success : function() {
}
});
}
Then I use the following in a passage to trigger the function:
<a id="cancel" href="#" onclick="sendAjax()">Send Ajax</a>
When I triger sendAjax, I get the following error:
"Error: ReferenceError: sendAjax is not defined."
What am I doing wrong? Any help you can provide would be greatly appreciated.
I've done some research on this, but everything I find doesn't seem to function properly. I'm trying to pass variables collected in twine to PHP so that I can print them as a txt file. I have worked out the PHP stuff, so that's not the issue, but when I try to pass twine variables via AJAX, I get an undefined error.
I'm using Twine v. 2.0.10 with SugarCube 1.0.32.
I'm collecting variables with the following:
Name: <<textbox "$name" "">>
Email: <<textbox "$email" "">>
Under story Javascript I have defined the sendAjax function:
//requires jquery
function sendAjax() {
$.ajax({
type: "POST",
url: "receive-ajax.php" ,
data: { name: state.active.variables.name, email: state.active.variables.email },
success : function() {
}
});
}
Then I use the following in a passage to trigger the function:
<a id="cancel" href="#" onclick="sendAjax()">Send Ajax</a>
When I triger sendAjax, I get the following error:
"Error: ReferenceError: sendAjax is not defined."
What am I doing wrong? Any help you can provide would be greatly appreciated.