The pit of ajax application/json

We are accustomed to using application/json to submit, so we will specify contentType in ajax.

$.ajax({
    url: "http://localhost:3000",
    type: "post",
    data: JSON.stringify({
        test: '123'
    }),
    contentType: "application/json",
    success: function (data) {
        console.log(data);
    }
})

But it is important to note that the data we submit must be a pure string. So generally use JSON.stringify() to convert it. Otherwise the backend cannot accept

But it is important to note that the data we submit must be a pure string. So generally use JSON.stringify() to convert it. Otherwise the backend cannot accept

But it is important to note that the data we submit must be a pure string. So generally use JSON.stringify() to convert it. Otherwise the backend cannot accept

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325367830&siteId=291194637