从ajax发布时出现错误请求错误

时间:2015-10-07 11:25:50

标签: jquery ajax

您正在尝试通过ajax传递数据并获得错误请求错误,请

 $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);
                    }
                });
       }

请检查错误enter image description here

任何帮助请尝试传递数据'{"CategoryId":"2"}';JSON.strinify,但没有任何建议

1 个答案:

答案 0 :(得分:0)

尝试将contentType添加到您的ajax正文

contentType: "application/json; charset=utf-8",