使用jQuery.ajax时是否可以访问和修改beforeSend中的数据?

Can I access and modify the data in beforeSend when using jQuery.ajax?

如标题所述,我正在使用jQuery.ajax方法post一组数据:

$.ajax({
    url: 'http://example.com/api',
    method: 'post',
    data: { name: 'dudu', age: 12 },
    beforeSend: function(xhr, settings) {
        // I want to change the data here.
    }
});

这可能吗?怎么样?

当然可以,下面是一个例子:

this.data = this.data.replace("12", "13");

请记住,此处数据已转换为字符串,因此您必须为更改操作字符串。