首页 > 解决方案 > 我通过 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));
                });



              }

标签: javascriptjsonajaxmobilesendy

解决方案


推荐阅读