I am using single page application via ajax in MVC but when I use window .history.pushstate and window. popstate I am getting an error like
Cross origin requests are only supported for protocol schemes: HTTP, data, chrome, chrome-extension, https.
send @ jquery-1.10.2.js:8720
ajax @ jquery-1.10.2.js:8150
load @ (index):468
window.onpopstate @ (index):426"
How to fix this issue? here my ajax call
<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>