0

Hi all following is my object

 $scope.myObject= {
    ID: { "value": "", "column": "ID" },
    Name: { "value": "", "column": "Name" },
    Desc: { "value": "", "column": "Desc" },
    IsActive: { "value": "", "column": "IsActive" },
    CreatedBy: { "value": "", "column": "CreatedBy" },
    ModifiedBy: { "value": "", "column": "ModifiedBy" },
    CreatedDate: { "value": "", "column": "CreatedDate" },
    ModifiedDate: { "value": "", "column": "ModifiedDate" },
    ConGp: { "value": "", "column": "ConGp" },
    SortIndex: { "value": "", "column": "SortIndex" },
    PageNumber: { "value":"", "column": "PageNumber" },
    PageSize: { "value": "", "column": "PageSize" }
}

value will get fill from html text box I want to pass this object in ajax call

  $.ajax({
                    url: url,
                    type: "GET",
                    data: JSON.stringify($scope.myObject),
                     success: function (data) {

                        $scope.FRP= data.RM;
                        $scope.$apply();
                    }

But on MVC Controller side data always get null value but while sending the object $scope.myObject the value is filled it is getting lost in ajax call. Please Suggest.

Ritesh Gore
  • 65
  • 10

2 Answers2

0

If you want to send data, use "POST" method. Either $.ajax or $http.post

Srigar
  • 1,648
  • 3
  • 14
  • 28
0

For sending data to DB/server we need to use the post request. If you are using MVC framework i would like to suggest you to use [axios][1]. Which is a Promise based HTTP client for the browser.

For your question :-

$.ajax({
  url: url,
  type: "POST",
  data: JSON.stringify($scope.myObject),
  success: function(data) {
    $scope.FRP = data.RM;
    $scope.$apply();
  }
});
Pradeep Gill
  • 318
  • 2
  • 9