0

Someone wrote me this piece of code a while ago for extracting a certain element(/data) of a website:

 $(function(){

   var site = 'http://www.telegraaf.nl'; 

   $.get('proxy.php', { site:site }, function(data){

      var href = $(data).find('h2').first().children(':first-child').prop('href');
      var url = href.split('/');
      href = href.replace(url[2], 'telegraaf.nl');


      $('.myDiv').html('<a href="' + href + '" target="_blank">' + href + '</a>');

   }, 'html');



});

It works well but not on this dutch news site: http://www.telegraaf.nl

Can someone explain to me why that is, what is so special about this website? What do I have to change to make it work?

Youss
  • 4,196
  • 12
  • 55
  • 109
  • What does proxy.php do? Does it alter the response body from telegraaf.nl in any way? – Michael Bird Sep 02 '12 at 16:38
  • @Michael Bird I think it's addressing php which I have on my server http://benalman.com/projects/php-simple-proxy/ I don't think it does anything to alter response of body – Youss Sep 02 '12 at 16:43

1 Answers1

1

This is probably happening because they use jQuery on telegraaf.nl too.

Have a look at the answers here: jQuery dialog over content from another site where someone experienced a similar problem. Guy mograbi's answer is very detailed and explains a lot.

Community
  • 1
  • 1
Terry Seidler
  • 2,043
  • 15
  • 28