jquery - How do I change the action on a form with javascript? -




i use laravel 5.3

my form :

{!! form::open(['route' => 'shop.process','id'=>'my-form']) !!}     ... {!! form::close() !!} 

if meets conditions, want change action

my condition in javascript :

if (true) {     $('#my-form').attr('action', '/shop/detail')     return true; } 

if condition met, success convert url this:

http://myshop.dev/shop/detail

but, content not display

content page appear when click url , enter

how can solve problem?

if want change content of form youll need load form ajax form area.

assuming /shop/detail form. should this. either using .load(), or .ajax()

if (true) {    $('#my-form').attr('action', '/shop/detail');    $('#my-form').load('/shop/detail');    return true; } 

or..

if (true) {     $('#my-form').attr('action', '/shop/detail')     $.ajax({        url:'/shop/detail',        success:function(data){            $('#my-form').html(data);        }      })    return true; } 

however, 2 methods above unlikely work, because doubt /shop/detail inner form. entire form. ie . means need replace element. not load data old form.

if (true) {     $.ajax({        url:'/shop/detail',        success:function(data){            $('#my-form').replacewith(data);            return true;        }      }) } 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -