开发者

split path name to get routing parameter

开发者 https://www.devze.com 2023-03-24 06:33 出处:网络
i am using mvc and jquery in my application i have the routing url like this : ID/Control开发者_Go百科ler/Action

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

ID/Control开发者_Go百科ler/Action

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


You can split the pathname from the moment you get it:

var pathname = window.location.pathname.split( '/' );

Once you have it split, you can access any part of the pathname as follows:

var path_id = pathname[1];
var path_controller = pathname[2];
var path_action = pathname[3];


  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

0

精彩评论

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