Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative form action resolves to absolute URL?

I am trying to get the actual string that is placed in a form action. The problem is when I do this, the action property resolves to an absolute path even though a relative path is in the HTML. How do I get the actual string that is in the action property?

Here is a sample of what I am referring to: http://jsfiddle.net/MSY4s/

like image 393
Basem Avatar asked Oct 26 '25 12:10

Basem


1 Answers

If you're already using jquery, I would use the .attr function rather than extracting the DOM element from the jQuery object. Like so:

$("form").attr("action");

That should give you literally what is in the action attribute. In the example you provided, that should look like "/somewhere". The second example in your jFiddle will show a full path since that's what is in the action attribute.

like image 134
Paul Richter Avatar answered Oct 28 '25 01:10

Paul Richter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!