Sadikhasan
Sadikhasan

Reputation: 18601

Change URL before form submit

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
});

Actual URL : /create_test1/54ae2be44a1bfef3138b4569

I want URL : /export_test1/54ae2be44a1bfef3138b4569

My Question is How to submit form after changing action?

Upvotes: 0

Views: 4819

Answers (1)

Qamar Aftab
Qamar Aftab

Reputation: 62

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

Upvotes: 1

Related Questions