开发者

Getting value from JS to PHP [duplicate]

开发者 https://www.devze.com 2023-04-07 17:28 出处:网络
This question already exists: Closed 11 years ago. Possible Duplicate: How to pass value from Javascript to PHP and get return of PHP back to Javascript
This question already exists: Closed 11 years ago.

Possible Duplicate:

How to pass value from Javascript to PHP and get return of PHP back to Javascript

how to get value from

JS:

var vars="";

and add it into PHP

$vars="";

Vars contains onl开发者_如何学编程y digits.


You'll have to send that variable with ajax or another kind of request to your server.

For example:

(JS):

var vars="123";
$.get('get_that_Variable.php?vars='+vars);

(PHP):

<?php
$vars = $_GET['vars'];


Its impossible for us to pass JS variable values to PHP variables cause PHP is a server side language and JavaScript is client side. Please understand that when your browser is running the JS codes PHP has already completed executing.

The only way that you will be able to do this is using AJAX. But thats a different story altogether.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号