0

In www.example1.com/demo.php I have a variable named

$x=5

I want to display the value of $x in www.example2.com

How to do it?

www.example2.com does not have server-side language support. Can I do it with JavaScipt or does it have a another way to accomplish it?

2
  • 1
    Just send the param as a query parameter in the URL (www.example2.com?x=5) and fetch it in the new site using JS. Here's a post about that Commented Oct 7, 2019 at 5:37
  • 4
    the short answer is AJAX Commented Oct 7, 2019 at 5:43

1 Answer 1

1

javascriptWantValue.js :

// show the waiting circle gif animation ;
$("#waitingCircle").css("display", "block");

$.ajax({
    url: "getValueFromPhp.php?"+paramOptional,
    dataType: "text",
    async: true,
    success: makeuseofValueFromPhp
});

function makeuseofValueFromPhp(valueFromPhp, status123, XHR123) {

    console.log("value from php is : " + valueFromPhp);

    // hide the waiting circle ;
    $("#waitingCircle").css("display", "none");

}// end function makeuseofValueFromPhp()

getValueFromPhp.php is :

<?php
    $x = 5;
    echo $x;
?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.