重定向而不离开当前页面 [英] redirect without to leave the current page

查看:62
本文介绍了重定向而不离开当前页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不离开当前页面的情况下使用 php 重定向请求的页面或需要 javascript?我需要它来在后台获取 cookie 或者从第三方获取 cookie 的最佳方法是什么?

is it possible to redirect the requested page with php without to leave the current page or it needs javascript? I need this to pick up a cookie in background or what is the best approach to get a cookie from a third party?

推荐答案

可以使用 JavaScript/jQuery 将内容动态加载到页面中.使用 $.ajax() 获取内容,然后加载使用 html()div(或其他选择器)中代码>.这样,页面保持不变(您保留 cookie),但您可以加载其他内容(而不是重定向).

It's possible to dynamically load content into a page using JavaScript/jQuery. Get the content with $.ajax() and then load the data into the selected div (or other selector) with html(). This way, the page stays the same (you retain cookies) but you can load additional content (rather than redirecting).

这篇关于重定向而不离开当前页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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