我通过javascript中的AJAX请求传递我的变量,但没有在我的php文件中获取它。不知道我哪里出错了。?
JS代码
var build = {
m_count : (document.getElementById('count').value),
}
$.ajax({
data: build,
type: "POST",
url: "tabs.php",});
PHP代码
<?php
$module_c = $_POST['data'];
echo $module_c;
?>
答案 0 :(得分:2)
您必须通过您想要获取的变量的名称来获取数据,即m_count。
totalcubes
编辑:
与评论中的建议一样,将您的JavaScript代码更改为:
THREE.InstancedBufferGeometry
答案 1 :(得分:0)
PHP:
<?php
$module_c = $_POST['m_count'];
echo $module_c;
?>
JS:
var build = {
m_count : (document.getElementById('count').value),
}
$.ajax({
url: 'php/server.php',
type: 'POST',
data: build,
})
.done(function(msg) {
// JSON.parse turns a string of JSON text into a Javascript object.
var message = JSON.parse(msg);
alert(message);
}
})
.fail(function(err) {
console.log("Error: "+err);
})
.always(function() {
console.log("Complete");
})