K
K
Konstantin2015-08-22 08:37:15
PHP
Konstantin, 2015-08-22 08:37:15

How to pass value of selected variable from php script to javascript (ajax)?

Good afternoon!
The question of how to send a specific value of a variable from a php script to ajax as a response is very interesting.
There is a feedback form that accepts data via ajax. In the php script, in addition to the function for processing the data received from the form, there are also others, so if you return

success: function(res) {
    ...
}

then all-all variables from this script will be displayed.

And how to pass the specific value of the $perem variable from the given php script as a response?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Zelensky, 2015-08-22
@SergeyZelensky-Rostov

echo json_encode( array('perem' => $perem));

F
Fedor, 2015-08-22
@whyamiscott

echo $perem

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question