From one php file I need to pass two ajax variables to two independent javascript files in the same isset condition
67
In php file:
if(isset($_POST["my_first_variable"]))
{
if(empty($_POST["my_first_variable"]))
{
//This $rtrn variable I need to return to another ajax function in
another javascript file
$rtrn["my_return_second_variable"]="First variable is empty";
echo json_encode($rtrn);
}
}
From first javascript file I send input data variable to php, where I check If that value is not empty and correct , If it is I need to send returning data to another javascript file that tells that input is empty or incorrect to disable submit button on main page.
Answer
Solution:
PHP cannot arbitrarily send data to some random file. It sends data back to the file which requested it.
You need your Javascripts to communicate with each other:
myscript.php
first.js
second.js
Make sure to load both of these files and it should work.
For the sake of anyone using Google, some common search phrases could be: