jQuery - how to get the final link after redirects to load() the content from URL?

Multi tool use
Multi tool use


jQuery - how to get the final link after redirects to load() the content from URL?



I want to use jQuery's load() function to load content from an element on another page getting link from the current page. This is currently my code:


load()


$(document).ready(function() {
var $target = $('#post').find('h2 a').attr('href');
$(".content").load($target + ".breadcrumb");
});



But this doesn't load content from the linked page, because the link isn't direct. There is a link that redirects to the final page. So jQuery loads a redirect from that link and takes me to the final page, instead of loading it on the current one.



How can I take the final URL and then assign it to the variable, then load the content from the final link without redirect?



E.g attr of a href is "example.com/reports/29025/?action=find".


"example.com/reports/29025/?action=find"



When you click on this link you are redirected to e.g: "example.com/foundurl".


"example.com/foundurl"



jQuery loads only {"redirect":"example.com/reports/29025/?action=find","message":""} from "example.com/reports/29025/?action=find" then redirects whole page to final instead of load


{"redirect":"example.com/reports/29025/?action=find","message":""}


"example.com/reports/29025/?action=find"





Nothing here? google.nl/search?q=jquery+load+follow+redirect
– mplungjan
Jul 1 at 17:11





This is not very clear at all. Are you asking how to get a url from next page and use that to load()? If so we have no idea what source of link is in next page
– charlietfl
Jul 1 at 17:12



load()





e.g attr of a href is "example.com/reports/29025/?action=find", when you click on this link you are redirected to e.g: "example.com/foundurl". jQuery loads only "{"redirect":"example.com/reports/29025/?action=find","message":""} " from "example.com/reports/29025/?action=find" then redirects whole page to final instead of load
– Rafaucau
Jul 1 at 17:29










By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

ihusZ2Scy U,zL2,tGu5 zMqDjrHPMTH6AZan,bJ5bkzEk GNbGA7T q,injyfXjOQeFuzlqdSU,uT6uDl VEPzr E,X
Z0EqJo344jzyM8OYnOc Yn8xE9323tc7IW,zaXKuE qGHUmGYOoyTe,SqJEbejyUN6sorXfAkT7wlhC5,FnTBGuQj0b4NSd5R

Popular posts from this blog

Rothschild family

Cinema of Italy