java - form action in html when jquery and ajax are used? -


i have below jquery/ajax code call servlet

$.ajax({         type: "post",         url: "./mycontroller",         data: datastring,         ............      }); 

i wrote jquery function called on submit click. mentioned url in ajax call above ./mycontroller.

in case should mention in form action ?

<form action="./mycontroller" 

in form action need mention url above ? because mentioned in ajax call above.

thanks!

action url in form not required here. although, can make use of form action in ajax call -

$('form').on('submit',function(e){     e.preventdefault(); // prevent default submit action     $.ajax({         type: "post",         url: this.action,         ...... })  

Comments