javascript - 我通过 post 方法将一个 json 对象发送到我的 sendy 数据库。它似乎在台式机上工作正常,但不能在移动设备上发送
问题描述
我通过 post 方法将 json 对象 userInfoRedCourses 发送到我的 sendy 数据库。此 json 对象是从上一页发送的,包含用户详细信息,如电子邮件、姓名、地址等。如果用户勾选该框,则发送数据。我还在发送数据之前更改了对象中的一些值。
这在台式机上运行良好,但在移动设备上根本不起作用。请问谁能解释一下为什么?
我认为这可能是一个 CORS 错误,但是当我添加 dataType: 'jsonp' 时,我停止收到 CORS 错误,但是使用移动设备时仍然没有发送数据。我没有看到其他错误。
var userInfoRedCourses = <%- JSON.stringify(userInfo) %>;
var redCourseTickYes = document.getElementById("redcoursetickyes");
var redLicence = $("#Redlicence").val();
var drivingBan = $("#drivingBan").val();
var penPoints = $("#penaltyPoints").val();
userInfoRedCourses.redcoursetickyes = $("#redcoursetickyes").val();
userInfoRedCourses.Redlicence = redLicence;
userInfoRedCourses.DrivingBan = drivingBan;
userInfoRedCourses.penaltyPoints = penPoints;
if(redCourseTickYes.checked){
var redCourses = {
method: "POST",
"data": userInfoRedCourses,
crossDomain: true,
url: "https://example.com/sendy/subscribe",
dataType: 'jsonp',
"headers": {
"Host": "example.com",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
}
};
$.ajax(redCourses).done(function (response) {
console.log(JSON.stringify(response));
});
}
解决方案
推荐阅读
- javascript - 具有多种颜色的三个.js 形状
- visual-studio-code - 有没有办法从 VS Code 中的自动格式化中省略某些代码部分?
- c# - 样式不适用于主视图以外的视图(asp.net core mvc 5.0)
- swift - 更改方案后反应本机 Bridge 崩溃
- multithreading - 第二种形式作为等待形式并更新其标签。[在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke]
- tensorflow - 如何在深度学习模型中制作软准确率和损失曲线
- r - 为什么我的 x 轴在我的数据结束之前被切断,当我尝试添加 xlim() 时出现错误?
- kubernetes - 如何让浏览器与不同的 Pod 对话?
- java - Hibernate InheritanceType 加入 PostgreSQL
- lotus-domino - 如何将 RFC822 内容读取为纯文本?