Looking for a quick cut/paste answer only. The following code was given to me by various users in different forums. I want to echo what's in the php to a dynamic textfield on the canvas.
php example:
<?
$ToName = "aaa";
$FromName = "bbb";
echo ($ToName);
echo ($FromName);
?>
ajax on the canvas:
this.frame_0 = function() {
let params = new URLSearchParams(window.location.search);
let EcardText = params.get("EcardText");
return $.ajax({
url: 'http://www.MYSITE.net/dBText/' + EcardText + '.php',
type: 'GET',
success: function (result) {
console.log(result);
},
error: function () {
console.log('error');
}
});
timeline.frame_0()
.then(res => {
console.log(res);
});
}
and this line is supposed to direct the data from the php to the designated textfield with the same instance name:
exportRoot.ToName.text =
The ajax code may be incomplete, might need data field, data type.. not sure how to fill out those fields.
Only asking for a fix to the code to make it all work. Not interested in detours (others suggested JSON, I really have no idea what that is or how it works.) All I know is that I need this as it is (php) to simply just work. Thanks.
What I have tried:
Tried the following:
exportRoot.ToName.text = 'test';
exportRoot.ToName.text = (result);
test shows test, so there's no conflicts on the name of the textfield receiving text.
result shows JohnDoe and JaneDoe in the same textfield, not what I want, but shows that the data is up for grabs, I don't don't know how to do it the right way...
Tried
exportRoot.ToName.text = $('ToName');
but it shows [object object] in the textfield.