简体   繁体   中英

Rails and AJAX - how to add parameters after call?

If you click on a photo on Facebook or Instagram, the photo with enlarge (probably) using AJAX and then are appended parameters about the photo to the URL.

How does it work? I would need something similar for menu items, but not sure under which term to search this.

You can change the URL in javascript at any point by just setting window.location , regardless of whether you're doing an ajax call or not. It depends a bit on whether you want navigation to actually take place, or if the javascript is just using the URL to store the values so that it can use them later or in a shared link. But basically you can do something like:

window.location = ' http://mydomain.com/thispage#param=1,param2=2 '

or whatever clever string manipulation you want to create the URL you're looking for.

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