0

Hi am trying to pass data through ajax and getting Bad request error any help please

 $scope.getSubCategory = function(id)
       {
           var category_id=id;
            var data = {"CategoryId":"2"};
           $.ajax({
                    url: "http://cashobby.abhigna.info/Services/CashobbyService.svc/subCategory",
                    type: "POST",
                    crossDomain : true,
                    dataType: "json",
                    data:data,
                    success: function (data) {
                            console.log(data);

                    },
                    //if wrong otp shoe user a error message

                    error: function (error) {
                        console.log(error);
                        // alert(request.responseText);
                    }
                });
       }

please check the errorenter image description here

any help please I have tried to pass data '{"CategoryId":"2"}'; and through JSON.strinify but no help any suggestion

Shaminder Singh
  • 1,283
  • 2
  • 18
  • 31
golucoder
  • 43
  • 1
  • 7

1 Answers1

0

try adding contentType to your ajax body as

contentType: "application/json; charset=utf-8",
Shaminder Singh
  • 1,283
  • 2
  • 18
  • 31