0

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?

Thanks in advance Arjun

tereško
  • 58,060
  • 25
  • 98
  • 150
A J
  • 45
  • 3
  • 13
  • 1
    http://stackoverflow.com/questions/20811779/how-to-change-browser-url-without-page-refreshing-in-nodejs/20811867#20811867 – WebServer Dec 28 '13 at 06:52
  • Pardom me if i seems a fool... This works for HTML 5 only rt? – A J Dec 28 '13 at 06:55
  • yes if browser is not supprting history api then you can fallback to hashed url's. – WebServer Dec 28 '13 at 06:57
  • 1
    How you are redirecting to another page ? Try using "window.location.href" – Pushkar Dec 28 '13 at 06:57
  • So, how can i check whether the browser supports it or not.When i tried it in chrome all went ok, but it crashed in IE. So is there a way to identify and set them accordingly – A J Dec 28 '13 at 07:00
  • http://stackoverflow.com/questions/824349/modify-the-url-without-reloading-the-page – Kamran Ahmed Dec 28 '13 at 07:04
  • Kamran, that's the code i implemented. But there is a problem like i specified above. Can you suggest any solutions for that? – A J Dec 28 '13 at 07:15
  • 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); } i used this and seems to work. any comments? – A J Dec 28 '13 at 07:57

1 Answers1

0

Did you tried this?

window.location = '/new/path';

You fire this code when ajax call is completed. Or even you can pass new url in ajax response.

shpyo
  • 221
  • 1
  • 6