0
如何設置AJAX函數調用的URL路徑,當我點擊頁面,然後該頁面的名稱應該是聲明的URL網站...如何設置URL路徑在阿賈克斯函數調用
例如:如果我點擊特定頁面(假設問堆棧溢出頁。)然後我的網址是這樣的:
stackoverflow.com/questions/ask
這裏我所說的AJAX功能:
<script type="text/javascript">
function getpage(obj, e) {
$('.page-sidebar-menu').find('a').removeClass('active');
$(e).addClass('active ');
$.ajax({
url:'@Url.Action("getcategory", "AbacusHome")',
type: 'GET',
// dataType: 'json',
data: { catname: obj },
success: function (data) {
$('#success').html(data);
}
});
}
這裏是從那裏我叫AJAX功能在錨標記我的網頁
@{
Layout = null;
}
@helper GetTreeView(Abacus_CMS.Models.AbacusModel siteMenu, int parentID)
{
var url = new System.Web.Mvc.UrlHelper(Context.Request.RequestContext);
foreach (var i in siteMenu.AbacusMenuList.Where(a => a.ParentCatagoryId.Equals(parentID)))
{
<li>
@{ var submenu = siteMenu.AbacusMenuList.Where(a => a.ParentCatagoryId.Equals(i.Id)).Count();}
@if (submenu > 0)
{
<li style="margin-left: -6px;">
<a href="#" class="hh active" onclick="return getpage('@i.Name',this)" id="@i.Name.Replace(' ', '-').ToLower() ">
<i class="fa fa-chevron-right" aria-hidden="true" style="margin-left: 25px; font-size: 10px;">
</i><span class="title" style="margin-left: 0px;">@i.Name</span>
<span class="arrow " style="height: 4px;"></span>
</a>
<ul class="sub-menu">
<li id="li1">@treeview.GetTreeView(siteMenu, i.Id)</li>
@* Recursive Call for Populate Sub items here*@
</ul>
</li>
@*<span class="collapse collapsible"> </span>*@
}
else
{
<img src="\Content\img\icon-round.jpg.jpg" style="margin-left:25px;margin-top:1px;position:relative;width: 5px;height: 5px;">
<a href="#" class="hh active" style="margin-left: 40px; margin-top:-20px;padding-bottom:15px;" onclick="getpage('@i.Name',this)" id="@i.Name.Replace(' ', '-').ToLower() ">
@i.Name
</a>
}
</li>
}
}
你能描述我詳細介紹 –
可以也可以使用document.URL,一個頁面是html中的一個文檔,任何一個頁面都有一個url –
你可以在我的代碼裏顯示我的代碼document.url –