Better JSON data structure

后端 未结 2 651
逝去的感伤
逝去的感伤 2021-01-24 03:01

I have following jQuery code and it works fine and I am able to deserialize it in the server properly.

But when I tried to create a variable and pass that as a JSON obje

2条回答
  •  旧时难觅i
    2021-01-24 03:49

    Your commented code passes a different object to the non-commented code

    Commented data (non-working):

    {
        searchCriteria: {
            Accrual: "A",
            Brand: "B"
        }
    }
    

    Uncommented data (working):

    {
        Accrual: "A",
        Brand: "B"
    }
    

    the original commented ajax request should be:

    $.getJSON(url, searchCriteria, function (data) {
        if (data.length) {
            alert('Success');
        }
    });
    

提交回复
热议问题