0

Problem in sending data if i will append all parameters to form Data than some of will not updating.

$scope.updateHospital = function(){
            $scope.spList = []; 
            var selected = $("#lstSpe option:selected");
                var message = [];
                selected.each(function () {
                    message.push($(this).val());
                });

                message.forEach(function(entry){
                    $scope.spList.push($scope.id[entry]); 
                });

            var formdata = new FormData();
            console.log($scope.name+$scope.des+$scope.spList);//all three fields have correct value in it

            formdata.append("name",$scope.name);
            formdata.append("description",$scope.des);
            formdata.append("primarySpecialty",$scope.spList);



            $http({
            method : 'PUT',
            url    : 'url',               
            headers : {"authorization" : access_token,"Content-type":undefined},
            data   :   formdata
            })

if i append "spList" to my form data than "name" and "description" is not updating the value when i send only "name & description" it is working fine. from postman this is working fine with all three values.

8
  • primarySpecialty should be primarySpeciality - too small an edit for me to make. Your method of gathering values does not seem like the 'angular' way. Have you considered making use of angulars two-way data binding rather than using jquery selectors? Commented Aug 11, 2016 at 9:07
  • no that is not a prblm that is just a typo mistake i have field with name "primarySpecialty". primarySpecialty is saving its data but the prblm is when i append "primarySpecialty" than name and description field is not saving their value Commented Aug 11, 2016 at 9:10
  • I don't see where $scope.name and $scope.des are assigned? Commented Aug 11, 2016 at 9:12
  • i have two input box on html form with ng-model="name" & ng-model="des" before appending the data i check the console value. they are giving me right values Commented Aug 11, 2016 at 9:15
  • i think their is prblm of serialization but i am not sure ! Commented Aug 11, 2016 at 9:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.