无效的JSON原始错误原始、错误、JSON

2023-09-11 00:50:48 作者:愿做你怀中猫

请帮助。在我的ajax调用收到错误无效的JSON原始的,什么是错这个下面Ajax调用

Please Help. In my ajax call getting error Invalid JSON primitive, whats wrong with this following ajax call

    $.ajax({
                url: "/Precedent/ShowPartyContents", type: "POST",
                contentType: 'application/json; charset=utf-8',
                dataType: 'html',
                data:{'partyId':party,'PartySelCombo':valueFrom,'DocumentId':DocId},
                sucess:function(result){
                    alert("String"+ result);
                    //jq("#PartyTagContentArea-"+ pass cheyyenda id).html(data).fadeIn();
                },
                error : function( ts ){ 
                    alert("error :(" + ts.responseText);


                }

            });

感谢

推荐答案

您是有希望的应用程序/ JSON 的内容类型,但是发送的是纯JS对象,它得到序列化为百分恩codeD-字符串的jQuery。这种序列化可能是远离有效的JSON。

You are promising a content type of application/json but are sending a plain JS Object, which gets serialised as percentile-encoded-string by jQuery. This serialization might be far from valid JSON.

修改

data: {'partyId':party,'PartySelCombo':valueFrom,'DocumentId':DocId},

data: JSON.stringify({'partyId':party,'PartySelCombo':valueFrom,'DocumentId':DocId}),