从离子到php

时间:2016-01-17 21:40:31

标签: php mysql angularjs ajax ionic-framework

我是离子的新手,我对使用ajax并不是很熟悉,我在下拉中获取所选值时遇到问题,我想使用ajax将其保存在我的数据库中..

我对离子的看法有3个选项值
   20分钟,30分钟和1小时

我想使用ng-model获取所选值。这是包含我的服务的代码。

    var returnRecipeData = {};

    return  {

        AddRecipe: function(thisrecipe){


            $http.post('http://localhost/admin-recipick/home/ajaxUserRecipe', thisrecipe).then(function(result){
                console.log(result);
            }, function(err){
                 console.error('ERR', err);
            });
        }

这是我的控制器。

    $scope.newRecipe={};

    $scope.AddRecipe = function() {
    console.log("Adding Recipe");
    UserRecipeList.AddRecipe($scope.newRecipe);
    //console.log($scope.signupdata);
    //var registerThis = StudentList.register($scope.signupdata);*/

    if(UserRecipeList.AddRecipe){
      console.log("Recipe Added Successfully");
      $scope.login();
      $ionicPopup.alert({
                  title: 'Recipe Added Successfully!'
              });
    }
    else{
       $ionicPopup.alert({
                  title: 'Failed to Add! Please Try Again!'
              });
    }

..最后我想使用ajax将所选值发布到我的sql数据库..

        $data = array('Recipe_ID'       => null,
                      'Recipename'      => $post->name,
                      'Ingredients'     => $post->ingredients,
                      'Cookingtime'     => $post->ctime,---> this is the part where i want to post the value to my database. but getting an error.
                      'Procedure'       => $post->procedure,
                      'user_id'         => 1

            );
        $this->db->insert('UsersRecipes', $data);
        echo json_encode($this->db->insert_id());
    }

...但我有内部服务器错误..请帮助..

0 个答案:

没有答案