Javascript 我在mvc中通过ajax使用单页应用程序?
我在MVC中通过ajax使用单页应用程序 但当我使用window.history.pushstate和window时。popstate我收到一个错误,如 跨源请求仅支持协议方案:HTTP、数据、chrome、chrome扩展、https。Javascript 我在mvc中通过ajax使用单页应用程序?,javascript,Javascript,我在MVC中通过ajax使用单页应用程序 但当我使用window.history.pushstate和window时。popstate我收到一个错误,如 跨源请求仅支持协议方案:HTTP、数据、chrome、chrome扩展、https。 发送@jquery-1.10.2.js:8720 ajax@jquery-1.10.2.js:8150 加载@(索引):468 window.onpopstate@(索引):426“ 如何解决这个问题?这里是我的ajax调用 <script>
发送@jquery-1.10.2.js:8720
ajax@jquery-1.10.2.js:8150
加载@(索引):468
window.onpopstate@(索引):426“ 如何解决这个问题?这里是我的ajax调用
<script>
$('#loadingImage').hide();
$('.jq-navigation-link').click(function () {
debugger
var url = $(this).data('url');
loadPartial(url)
})
function loadPartial(url)
{
debugger
$('#renderPartial').html("");
$('#loadingImage').show();
$.ajax({
url: url + "?ispartial=" + true,
type: "GET",
success: function (data) {
debugger
$('#loadingImage').hide();
$('#renderPartial').html(data);
}
})
window.history.pushState({ url: url }, '', url);
window.onpopstate = function (event) {
debugger
if (event.state)
{
var previousUrl = "location: " + document.location + ", state: " + JSON.stringify(event.state);
loadPartial(previousUrl);
}
};
}
</script>
$(“#加载图像”).hide();
$('.jq导航链接')。单击(函数(){
调试器
var url=$(this.data('url');
loadPartial(url)
})
函数loadPartial(url)
{
调试器
$('#renderPartial').html(“”);
$(“#加载图像”).show();
$.ajax({
url:url+“?ispartial=“+true,
键入:“获取”,
成功:功能(数据){
调试器
$(“#加载图像”).hide();
$('#renderPartial').html(数据);
}
})
window.history.pushState({url:url}',,url);
window.onpopstate=函数(事件){
调试器
if(事件状态)
{
var previousUrl=“位置:”+document.location+”,状态:“+JSON.stringify(event.state);
loadPartial(以前的URL);
}
};
}
您需要使用http服务器
这可能会解决您的问题。您是否使用文件://?@plumSemPy,我想没有