Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
PHP
<?
$ToName = "aaa";
$FromName = "bbb";
echo ($ToName);
echo ($FromName);
?>


ajax on the canvas:
JavaScript
	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');
        }
});
//when you call this function
timeline.frame_0()
    .then(res => {
        //do something with the result only here
        console.log(res);
    });
	}


and this line is supposed to direct the data from the php to the designated textfield with the same instance name:
JavaScript
exportRoot.ToName.text = //I want the echo of ToName from the php to go here


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:
JavaScript
exportRoot.ToName.text = 'test';

JavaScript
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
JavaScript
exportRoot.ToName.text = $('ToName');

but it shows [object object] in the textfield.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900