javascript - 从ajax发送数据到php返回NULL
问题描述
我试图将数据从 ajax 发送到 php。
当我试图提醒它时,它工作得很好,但是当我试图发布数据时它没有工作。
我的阿贾克斯
function onBtnClick(event){
var nah = JSON.stringify(points);
alert(nah);
$.ajax( {
url:"../php/points.php",
type:'post',
data: {point:nah},
success: function(response){
window.location = "../php/points.php";
}
})
}
我试图发布的观点
points[currentid] = {id: currentid, x: event.offsetX, y: event.offsetY};
currentid++;
php代码
if(isset($_POST['point'])){
$user = $_POST['point'];
$decoded = json_decode($user, true);
var_dump($decoded);
echo $decoded;
}
解决方案
推荐阅读
- gremlin - 如何在 Gremlin 遍历中使用 sideEffect 和 dedup?
- cors - 在 Netlify 函数中强制同源?(cors)
- javascript - 为什么我的 javascript 不能在 wordpress 中工作(我是否以正确的方式链接它)
- google-cloud-platform - 如何设置 GCS 存储桶的限制
- sql - postgresql 可以共享只读会话吗?
- php - php代码在所有浏览器中的工作方式都不一样
- flutter - Flutter App 未构建(Gradle 问题)| 卡在 assembleDebug
- wpf - WPF - 当可见性为折叠时如何不更新布局
- pointers - 用“void*”转换“char”指针并取消引用它
- ios - iOS - Firestore 多次检索相同的数据