我通过 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));
});
}