【发布时间】:2014-05-21 17:15:02
【问题描述】:
document.getElementById('user-name').onkeyup = function () {
connection.extra['user-name'] = this.value;
};
document.getElementById('setup-voice-only-call').onclick = function () {
this.disabled = true;
connection.open();
};
connection.extra = {
'user-name': 'Anonym'
};
我有一个 PHP 网站,用户可以登录。我正在使用$_SESSION['username']。
如何在上面的 JavaScript 代码中将变量 user-name 更改为 session['username']?
【问题讨论】:
-
在页面生成时将php值嵌入到JS代码中,或者使用ajax请求获取。
标签: javascript php session variables