Moose
Moose

Reputation: 152

How do I get the current url/path in JS for Ajax?

I need to send a request to the current url.

Upvotes: 2

Views: 1214

Answers (2)

Serge K
Serge K

Reputation: 375

Just send AJAX to empty "" URL. This will be current url of the page.

Upvotes: 1

Moose
Moose

Reputation: 152

Use Window.location.origin

and append Window.location. pathname to get the full path (No hash or params)

Upvotes: 0

Related Questions