jquery ajax清除缓存的方法

function cityListChange(cityCode){
          //{lon=121.491121, name=上海, province=上海市, telPrefix=021, provinceid=310000, code=310100, lat=31.243466, platePrefix=沪}

        $.ajax({
            type: "get",
            dataType: "json",
            url: "${contextPath}/carUpload/cityList/" + cityCode +"?random="+Math.random(), //url后加入随机数参数,防止缓存,
            success: function (result) {

                $("#cityLon").val(result.data["lon"]);
                $("#cityLat").val(result.data["lat"]);
                $("#province").val(result.data["provinceid"]);
                $("#city").val(result.data["code"]);
                $("#cityTelCode").val(result.data["telPrefix"]);
                $("#platePrefix").val(result.data["platePrefix"]);
                
                var lon = result.data["lon"];
                var lat = result.data["lat"];
                $("#carAddressImg").attr("src", "http://restapi.amap.com/v3/staticmap?location="+lon+","+lat+"&zoom=8&size=550*350&key=ee95e52bf08006f63fd29bcfbcf21df0");
                
            }
        });
      }
注意:+"?random="+Math.random(), //url后加入随机数参数,防止缓存,

转载于:https://www.cnblogs.com/simpledev/p/3898905.html

你可能感兴趣的:(jquery ajax清除缓存的方法)