[前端][fmui] 页面ajax请求无法重定向问题

问题现象

示例知识库1open in new window

示例知识库2open in new window

排查问题 ajax 发出去的请求 302 没办法跳转页面。

解决方案

通过添加X-Requested-With请求头方便后端判断为ajax请求,不进行直接重定向,而是通过返回status: code:307和url 来进行跳转页面。

  • Util.ajax请求:配置xRequestedWith属性,值为true
Util.ajax({
    url: url,
    type: type,
    dataType: 'json',
    contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
    data: data,
    xRequestedWith:true,
    success: function (data) {},
    error: function (data) {},
});
  • epointm.execute或epointm.refresh请求:FMUI951及以上版本已默认携带上X-Requested-With请求头,无需做调整
最后更新时间::
贡献者: wyanqd