首页 > 解决方案 > 覆盖发布请求

问题描述

我将这段代码放在控制台中:

XMLHttpRequest.prototype.send = function(body) {
    // modifies inputted request
    newBody = JSON.parse(body);
    newBody.points = 417;

  // sends modified request
    this.realSend(JSON.stringify(newBody));
}

它应该在每次发送请求时都获得417分,但是当我查看请求正文时,它仍然显示原来的积分数量。有什么帮助吗?

标签: javascripthttpxmlhttprequesthttp-post

解决方案


尝试将alert()or添加console.log()到您的修改XMLHttpRequest.prototype.send中以检查它是否确实有效。有一种方法可以静默地防止这种修改。


推荐阅读