简体   繁体   中英

How can I redirect to another page in ajax with data?

I have managed to save a form and returned success. I want to redirect to another page using window.location.href = '/home';which is working well. I however want to pass the success message to the home page after redirecting. When I use window.location.href = '/home'+ data; the message concatenates with the URL. How do I go about this?

Can you share your code to help with your question?

Maybe you can use something like this:

return view('YOUR VIEW', compact('data'));

If that doesn't work, you could use LocalStorage :

localStorage.setItem("data", data);
window.location.href = '/home';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM