gpt4 book ai didi

javascript - 表单提交前更改 URL

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

HTML

<form id="form" method="post" action="/create_test1/54ae2be44a1bfef3138b4569">
.
.
.
<input type="button" id="export" value="Export">
</form>

jQuery

$("#export").click(function(){
url = $("#form").attr("action");
url = url.replace("create_test1","export_test1"); // This is OK
$('#form').attr('action', url).submit(); //Here form is not submited
});

实际网址:/create_test1/54ae2be44a1bfef3138b4569

我想要网址:/export_test1/54ae2be44a1bfef3138b4569

我的问题是更改操作后如何提交表单?

最佳答案

 $("#export").click(function()
{
$('#form').attr('action', '/export_test1/54ae2be44a1bfef3138b4569');
});

关于javascript - 表单提交前更改 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27835851/

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