首页 > 解决方案 > 在 jQuery ajax post 方法中出现错误 400

问题描述

如何解决?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
          var option = {
                method: 'POST', 
                url: 'https://api.hesabfa.com/v1/item/save',
                data: {
                    apiKey: '********',   
                    userId: '********',   
                    password: '********',  
                    item:{                
                        Name: 'name',
                        Barcode: '345345345345',
                        ItemType: 0,
                        Unit: 'k',
                        BuyPrice: 500000,
                        SellPrice: 550000,
                        PurchasesTitle: 'Samsung Galaxy J7',
                        SalesTitle: 'Samsung Galaxy J7',
                        Tag: ''
                    }
                }
            }
            $.ajax(option).done(function(result) {
                if (result.Success)
                  
                var r = result.Result;   
            })
            .fail(function() {
            });
    
</script>

标签: javascriptjqueryajax

解决方案


请检查 hesabfa API 文档和必填字段,也许你错过了一些东西。


推荐阅读