Skip to main content
Participant
May 3, 2021
Question

Animate read variables in PHP page and print on screen

  • May 3, 2021
  • 1 reply
  • 865 views

Hello

I wanted Animate to read variables (text) from a PHP page (echo $word;) and print them on the screen.
I had that functionality working in Flash / ac3, but now with Animate I can't.
I can't find any clues how to do it in the forums about Animate.
I'm asking for your help.
Thanks!

 

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 4, 2021

var xmlhttp;

var tf = this.your_text_field;

if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
tf.text = xmlhttp.responseText;
}
}

xmlhttp.open("GET", "your_php_path_file.php", true);
xmlhttp.send();

Rui5E42Author
Participant
May 6, 2021

Hello

Kglad, Adobe Community Professional

It works! Thanks a lot!

You guys are awesome, great company.

I leave simplified code/example:

 

PHP:   s1.php

<?php
$texto_1="Olá Arbor!";
echo $texto_1;
?>

 

ACTION:

var tf = this.texto_1;

if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
tf.text = xmlhttp.responseText;
}
}

xmlhttp.open("GET", "s1.php", true);
xmlhttp.send();

 

 

kglad
Community Expert
Community Expert
May 6, 2021

good to hear