0

Possible Duplicate:
Ajax cross domain call

To with this code here ..

   var URLs = new Array();
   var titulo = new Array();

   $.ajax({
     url: 'http://www.example.com.br',
     type: 'GET',                                                    
     success: function(res) {
       headline = $(res.responseText).text();                                                              
       URLs = headline.split(",LK");
       CriaVideos(URLs);                               
    }
   }); 

  function CriaVideos(URLs)
  {                           
   for(var i = 0; i <= 5; i++)
   {
    var aux = new Array();
    aux = URLs[i].split("#");

    titulo.push(aux[0]);
    titulo.push(aux[1]);
    Cria(titulo);
   }                   
  }                                           

 function Cria(titulo)
 {                                                                   
   document.write('<li><div id="frame_video"><a href="TelaVideoWind.php?nome='+       titulo[1]+ '&video=' + titulo[0] + '"><span class="frame_video_img"><img src="img/play.png" width="60px" height="40px" align="middle" style="position: absolute; margin-top: 55px; margin-left: 95px;"/><img src="http:/'+ titulo[0]+ '/i.ytimg.com/vi/hqdefault.jpg" width="250px" height="150px"/></span><span class="frame_video_desc"></span></a></div></li>');                          
 }

And would it work in the title document.write or take it outside the function but it is not working! I wonder if anyone can help!

Community
  • 1
  • 1

1 Answers1

0

As Felix Kling mentioned cross domain calls like this aren't allowed by most browsers. There are a couple of ways to get around this like http://en.wikipedia.org/wiki/JSONP, but this requires what you're hitting is a JSONP service I believe.

Alternatively you can use a proxy page in whatever web lang you're using. So you could have a php page do a server to server request that gets the page that you're currently sending your ajax request to. Then your proxy page can serve up the content/response it got from its server to server call to the ajax call.

ZapRowsdower910
  • 3,024
  • 1
  • 17
  • 14
  • So .. But I'm in the same domain .. I just wanted to treat this string coming from the same domain and put the title in the array document.write to create the components of videos! But they said that is only possible deal going from one function to another .. Somehow I have to get this array and use elsewhere? Or any better solution for this – user1754616 Oct 18 '12 at 17:54