Proper way to handle 304 not modified in jQuery ajax

后端 未结 2 1956
Happy的楠姐
Happy的楠姐 2021-02-18 23:02

As of jQuery 1.5, the ajax methods now correctly handle 304 Not Modified responses by calling the success() handler, as per the W3C spec for XMLHTTPRequest. This allows your ap

2条回答
  •  别跟我提以往
    2021-02-18 23:24

    Depending on context, you could use the cache parameter to the ajax request:

    $.ajax({
        url: ".....",
        dataType: "json",
        type: "GET",
            cache: false,
        contentType: "application/json",
            success: function (data, textStatus) {
                console.log("RECV: " + data);
            }
        });
    

    That's working for me.

提交回复
热议问题