How do I echo my php to textfield on canvas?
Hi all, my project is all done, save for this little morsel. Using a small example here. Need to echo the php to a dynamic text box on the canvas.
Here's a php file and its contents:
<?
$ToName = "JohnDoe";
$FromName = "JaneDoe";
echo $ToName;
echo $FromName;
?>The ajax on the canvas that calls the php file:
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: 'POST',
success: function (result) {
console.log(result);
},
error: function () {
console.log('error');
}
});
//when you call this function
timeline.frame_0()
.then(res => {
//do something with the result only here
console.log(res);
});
}The php file loads and appears in network tab on F12 in the browser. The values John Doe and Jane Doe also appears in the console. After that, all I need to do is execute some lines like this:
this.ToName.text = ToName from my php, should say John DoeI'm just not sure how to phrase it...
Now out of curiosity, I put the following where it says "do something with the result only here" but nothing happens:
this.ToName.text = 'test';
Tried it in frame1, it writes test no problem to the textbox. Not sure why it won't execute in the do something with results area, which is where it should be if it's gonna grab the value from the php, right?
Thanks all! Stay well.
