0
我正在开发一个使用ASP.NET MVC的网页。当我使用aJax请求子页面内容时,url附加了一个“#”automatic.Before阿贾克斯,URL可能是这样的:http://a.travel.com/product/index,AJAX请求后,URL将是这样的:http://a.travel.com/product/index#。这是我的Ajax请求的代码:如何避免url aotomatic在ajax请求后追加“#”符号
function GetProductByTag(tagId, source) {
var keyword = $("#serachInput").val();
if (keyword == null) {
return;
}
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
document.getElementById("productList").innerHTML = xhr.responseText;
} else {
xhr.abort();
alert("Too many request!");
}
}
}
xhr.open("Post", "/Product/ProductList?tagId=" + tagId + "&pageIndex=1", true);
}
xhr.send(null);
}
响应文本是产品列表信息(HTML )。
这是我的网页列表部分代码:
<li onclick="ClickProductList(1,'http://www.ly.com/scenery/BookSceneryTicket_2287.html?spm=1.68076534.156.4&refid=75866398')" class="top">
<a href="#">
<img src="/WCF_UploadFile/TourProductPhoto/20160125143157LWTIW.jpg">
<h6>
<span>35</span>
</h6>
<p></p>
</a>
</li>
为什么会出现这种情况,如何避免?
[防止HREF = “#” 从改变URL散列链接](的可能的复制http://stackoverflow.com/questions/20215248/prevent-href-link-from-changing -the-url-hash) – JJJ
你如何调用'GetProductByTag'? –