浏览器网址没有变化 [英] browser url not changing

查看:87
本文介绍了浏览器网址没有变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i我正在尝试学习MVC,在我的页面中有两个动作

1.更新

2.删除



我使用AJAX使用提交和删除进行了更新。删除成功后,我想重定向到页面。我实现了它,但问题是浏览器的URL。它仍然显示编辑页面网址。那么有什么方法可以解决这个问题吗?



删除方法



Hi,

i am trying to learn MVC and in my page there are two actions
1. Update
2. Delete

I did update using submit and delete using AJAX. When delete is successful,i want to redirect to a page. I achieved it but the problem is the URL of browser. It still shows the edit page url. So is there a way i can solve this?

Delete method

$.ajax({
                url: "/" + controller + "/" + action + "/" + id + "/",
                type: "Get",
                cache: false,
                error: (function (error) { alert(error) }),
                success: (function (response) {
                    $("#Content").html(response);
                    document.title = response.pageTitle;
                    //window.history.pushState({ "html": response.html, "pageTitle": response.pageTitle }, "", urlPath);
                    if (history.pushState) {
                        //history.pushState(null, null, '#myhash');
                        window.history.pushState({ "html": response.html, "pageTitle": response.pageTitle }, "", urlPath);
                    }
                    else {
                        window.location.pathname = urlPath;
                        // window.history.pushState({ "html": response.html, "pageTitle": response.pageTitle }, "", urlPath);
                    }

                    //alert(data);
                })
            });







提前致谢

Arjun




Thanks in advance
Arjun

推荐答案

.ajax({
url:/+ controller +/+ action +/+ id +/,
类型:获取,
缓存:false,
错误:(功能(错误){alert(错误)}),
成功:(功能(响应){
.ajax({ url: "/" + controller + "/" + action + "/" + id + "/", type: "Get", cache: false, error: (function (error) { alert(error) }), success: (function (response) {


(#Content)。html(response);
document.title = response.pageTitle;
//window.history.pushState ({html:response.html,pageTitle:response.pageTitle},,urlPath);
if(history.pushState){
//history.pushState(null,null, '#myhash');
window.history.pushState({html:response.html,pageTitle:response.pageTitle},,urlPath);
}
els e {
window.location.pathname = urlPath;
// window.history.pushState({html:response.html,pageTitle:response.pageTitle},,urlPath);
}

//警报(数据);
})
});
("#Content").html(response); document.title = response.pageTitle; //window.history.pushState({ "html": response.html, "pageTitle": response.pageTitle }, "", urlPath); if (history.pushState) { //history.pushState(null, null, '#myhash'); window.history.pushState({ "html": response.html, "pageTitle": response.pageTitle }, "", urlPath); } else { window.location.pathname = urlPath; // window.history.pushState({ "html": response.html, "pageTitle": response.pageTitle }, "", urlPath); } //alert(data); }) });







提前致谢

Arjun




Thanks in advance
Arjun


这篇关于浏览器网址没有变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆