开发者

jquery getting post action url

开发者 https://www.devze.com 2022-12-25 18:24 出处:网络
I\'m trying to access the post target action in a jquery func开发者_Python百科tion. example: <form action=\"/page/users\" id=\"signup\" method=\"post\">

I'm trying to access the post target action in a jquery func开发者_Python百科tion.

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!


$('#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');


Clean and Simple:

$('#signup').submit(function(event) {

      alert(this.action);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消