Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 没有对ajax PUT的响应,但是对ajax GET和POST的响应_Javascript_Jquery_Ajax_Xmlhttprequest_Put - Fatal编程技术网

Javascript 没有对ajax PUT的响应,但是对ajax GET和POST的响应

Javascript 没有对ajax PUT的响应,但是对ajax GET和POST的响应,javascript,jquery,ajax,xmlhttprequest,put,Javascript,Jquery,Ajax,Xmlhttprequest,Put,进行相同的域(->)POST时,responseXML包含预期的数据。发出相同的请求,但作为PUT,对于成功的请求,responseXML为null。我正在使用jQuery.ajax,但我也测试了一个手动实现,结果相同 var settings = { url: '//' + window.location.host + window.location.pathname, type: getRequestType(), contentType: 'application/

进行相同的域(->)POST时,responseXML包含预期的数据。发出相同的请求,但作为PUT,对于成功的请求,responseXML为null。我正在使用jQuery.ajax,但我也测试了一个手动实现,结果相同

var settings = {
    url: '//' + window.location.host + window.location.pathname,
    type: getRequestType(),
    contentType: 'application/json; charset=utf-8',
    dataType: 'json',
    data: JSON.stringify(parms),
    error: function(jqxhr, status, error) {
        console.log('error');
    },
    success: function(data, status, jqxhr) {
        console.log('success:', data);
    }
};
$.ajax(settings);
我使用一个非常简单的服务器请求处理程序,它返回一个简单的json格式字符串

@require_http_methods(["PUT"])
def proxy_update(request):
    out = {
        'type': 'update',
        'success': True
    }
    return HttpResponse(json.dumps(out), mimetype="application/json")

对此有何解释?

根据jQuery文档,并非所有浏览器都支持所有动词。很可能您使用的浏览器不支持PUT动词。尝试其他浏览器。如果浏览器未出现故障,则服务器也可能被配置为忽略PUT动词。

结果表明是两种可能原因中的后一种。