我想加载一个 php 变量并将其用于 javascript
$(document).ready(function() {
$('#reload').load('http://www.domain.de/content/entwicklung/reload.php?uid=' + uid_clear + '');
});
从这段代码中我得到一个 var
但我只能将其加载到 div
if (uid_clear == ..) {
// want to replace the dots with the data from .load
document.write(' Allgemeine Reloadsperre für das Mitglied von 30 Minuten');
}
如何将 data
加载到 div
中并将其用作 javascript var
?有什么方法可以传输/更改它,或者是否可以将数据作为 javascript var 加载?
亲切的问候
最佳答案
像这样使用$.get
:
$.get( 'http://www.domain.de/...', function( data ) {
if (uid_clear == data) {
// want to replace the dots with the data from .load
document.write(' Allgemeine Reloadsperre für das Mitglied von 30 Minuten');
}
});
查看the documentation有关 get
方法的更多信息。
关于javascript - 使用 jquery 加载 php 变量并使用 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30524518/