Search code examples
javascripturl-parsing

split path name to get routing parameter


i am using mvc and jquery in my application i have the routing url like this :

ID/Controller/Action

I want to get the URL and split it to get the id in jquery


Solution

  •   var pathname = window.location.pathname;
      var appId = pathname.split('/')[1];
    

    i see that your first param is the id with this piece of code you can get the id in jquery