I'm trying to access the post target action in a jquery function.
example:
<form action="/page/users" id="signup" method="post">
I'd like to access the "action" part - "/page/users" in this case.
$('#signup').live("submit", function(event) { // get this submitted action }
Seems like I'm missing something very simple. I see the value in the dom but don't know where it's stored in jquery.
Thanks!
prop() returns the full action url: To use the action attribute of a form use: $( '#myForm' ). attr( 'action' ); like @JAAulde said.
The jQuery post() method sends asynchronous http POST request to the server to submit the data to the server and get the response. Syntax: $. post(url,[data],[callback],[type]);
get() method requests data from the server with an HTTP GET request. Syntax: $. get(URL,callback);
$('#signup').on("submit", function(event) { $form = $(this); //wrap this in jQuery alert('the action is: ' + $form.attr('action')); });
Try this ocde;;
var formAction = $("#signup").attr('action');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With