且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将JSON数据发送到服务器错误

更新时间:2023-01-01 16:51:57

问题与JSON数组有关.这不是从客户端发送到服务器的有效JSON字符串.

Problem was about the JSON array. It was not a valid JSON string that was sent from client to server.


编辑

为了澄清这一点,我偶然发现了这篇文章.需要在Ajax请求中执行正确的JSON.stringify(data).奇怪,但是在设置相应的dataType.ajax函数无法完成.

To clarify this, I stumbled upon this post. It is required to do a proper JSON.stringify(data) in the Ajax request. It's strange but it's not done by the .ajax function when setting the corresponding dataType.

$.ajax({
    async : false,
    type:'POST',
    url: '/uxiy/webapp/uxmer',
    data: JSON.stringify(user),
    dataType: 'json',
    success: function(data) {
        ...
    },
    error: function(data) {
        ...
    }
});