Click here to Skip to main content
15,885,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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);
                })
            });



Thanks in advance
Arjun
Posted
Updated 27-Dec-13 21:06pm
v2
Comments
Sampath Lokuge 28-Dec-13 2:48am    
can you put the code snippet for the ajax delete method ?
Arjun Menon U.K 28-Dec-13 2:59am    
$.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);
})
});


This is working. If anything is not correct please correct me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900