离子应用程序ajax调用在浏览器中使用" ionic serve"但不能在ios设备上使用"离子上传"

时间:2016-08-10 17:29:52

标签: ios angularjs ionic-framework

已经在这个问题上突破了3天。该应用程序可在浏览器中使用,但不适用于ios设备。如果我从ajax调用中提醒数据,它将在ios设备上返回null。

REGISTER.HTML

<div ng-controller='MainCtrl'>
      <div class="list">
        <span>test{{responseMessage}}</span>
        <label class="item item-input item-stacked-label">
          <span class="input-label">Username</span>
          <input class="form-control" type="text" ng-model="username" placeholder="Username">
        </label>
        <label class="item item-input item-stacked-label">
          <span class="input-label">Email</span>
          <input class="form-control" type="text" ng-model="email" placeholder="Email">
        </label>
        <label class="item item-input item-stacked-label">
          <span class="input-label">Password</span>
          <input class="form-control" type="password" ng-model="password" placeholder="Password">
        </label>
        <label class="item item-input item-stacked-label">
          <span class="input-label">Password retype</span>
          <input class="form-control" type="password" ng-model="retypepassword" placeholder="Retype password">
        </label>
        <button class="button button-block button-positive" ng-click="register()">Register</button><br>
      </div>
    </div>

APP.JS

.controller('MainCtrl', function($scope, $ionicSideMenuDelegate, $http) {

$scope.register = function () {

        var request = $http({
            method: "post",
            url: "https://www.dummylink.com/app/php/register.php",
            data: {
                username: $scope.username,
                email: $scope.email,
                password: $scope.password,
                retypepassword: $scope.retypepassword
            },
            headers: { 'Content-Type': 'application/x-www-form-urlencoded'}
        });
        request.success(function (data) {
              $scope.responseMessage = data;
        });
        request.error(function (data) {
              alert(data);
        });
}

})

1 个答案:

答案 0 :(得分:0)

首先非常感谢tommybananas试图帮助我!最终问题与CORS无关。

问题是我的ssl证书安装不正确。我删除了它并再次安装它。现在一切正常!