1

使用 easyXDM 时,我遇到了 PUT 请求问题。其他操作,如 POST、DELETE 工作正常。最初它将数据放在查询字符串中。尝试关注另一篇文章:easyXDM PUT将数据放入查询字符串

更改代码后,它现在在 Request Payload 中发送数据,但数据格式不正确,这导致了错误的请求。

putJson = function (url, request, success_callback, error_callback, custom_headers) {
        if (typeof (custom_headers) == "undefined") {
            custom_headers = {};
        };
        //custom_headers.Accept = "application/json";

        this.rpcSocket.request({
            url: url,
            method: "PUT",
            dataType: 'json',
            headers: { "Content-Type": "application/json"}, 
            data: request
        },
        function (response) {
            success_callback(response);
        },
        function (error_response) {
            if (_.isUndefined(error_callback) || !_.isFunction(error_callback)) {
                ajaxError.call(error_response);
            }
            else {
                error_callback(error_response)
            };
        });
    }
4

0 回答 0