Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49186

How to pass data from data binded form

$
0
0

@parabahis wrote:

Hi everyone, i try to explain my issue and i hope i can do it. I try to post data with hidden text inputs to my server (PHP). I use this for data binding :

<form ng-submit="addfavourite()">
      <input type="hidden" ng-model="data.mac_id" ng-value="veri.mac_id">
      <input type="text" ng-model="data.user_id" ng-value="myuser">
      <input type="submit" value="" class="favourite">
  </form>

And i try to get data into my controller like this :slight_smile:

 $scope.data = {};

$scope.addfavourite = function(){

    var links = 'http://www.website.com/api.php';
    $http.post(links, {user_id : $scope.data.user_id, mac_id : $scope.data.mac_id}).then(function (res){
        $scope.response = res.data;
        if ($scope.response == 1) {
          $scope.messages = 'Eşleşme sağlandı.';
        }
        else if ($scope.response == 0)
        {
          $scope.messages = 'Eşleşme sağlanmadı.';
        }
    });
};

But i get this error :

ionic.bundle.js:26794 SyntaxError: Unexpected token E in JSON at position 0
    at fromJson (ionic.bundle.js:14655)
    at defaultHttpResponseTransform (ionic.bundle.js:23675)
    at ionic.bundle.js:23766
    at forEach (ionic.bundle.js:13691)
    at transformData (ionic.bundle.js:23765)
    at transformResponse (ionic.bundle.js:24554)
    at processQueue (ionic.bundle.js:29127)
    at ionic.bundle.js:29143
    at Scope.$eval (ionic.bundle.js:30395)
    at Scope.$digest (ionic.bundle.js:30211)

So i found the reason to see this error. I bind data into inputs with ng-value. And if i write something into the textbox manually it works. But it doesn't work with only ng-value datas and get this error.

So how can i get this values from the form into my controller for post ot my server?

Can anyone help about this please.

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 49186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>