gpt4 book ai didi

javascript - 更改表单序列化数据

转载 作者:行者123 更新时间:2023-12-03 06:24:28 25 4
gpt4 key购买 nike

在 JS 表单序列化之后,我有这个:

.....&xx=xxx&otherError=&input=SMS&message=sdfgs&......

如何在 ajax 调用放置 textarea val 之前更改 message val?

提前致谢,

史蒂夫

最佳答案

使用 String#replace 方法更新字符串。

var str = '.....&xx=xxx&otherError=&input=SMS&message=sdfgs&......';

str = str.replace(/&message=[^&]+/, '&message=newvalue');

console.log(str);

<小时/>

或者在序列化之前更新输入字段值。

$('[name="message"]').val('newvalue');

关于javascript - 更改表单序列化数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38717638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com