G
G
Gonlif2015-12-12 14:46:08
PHP
Gonlif, 2015-12-12 14:46:08

How to pass a variable to PHP via AJAX?

Hello, I have never worked with AJAX and have not completely smoked the documentation on it. Can you please tell me how can I display "response.session.mid" through a variable in php?

<script language="javascript">
VK.init({
  apiId: ******
});
function authInfo(response) {
  if (!response.session) {
  alert('not auth');
  } else {
    alert(response.session.mid)
 }
}
VK.Auth.getLoginStatus(authInfo);
  VK.UI.button('login_button');
</script>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton Shcherbakov, 2015-12-12
@WestTrade

Just push the variable into:

$.ajax
data:{}

And check on the server for the existence of a variable in the accepted request, then create a condition.

A
Aitd, 2015-12-12
@Aitd

alert(<?php echo $val; ?>);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question