having issues calling for youtube data : /

3 views
Skip to first unread message

Peacemaker

unread,
Jan 20, 2010, 1:48:14 PM1/20/10
to Google Data Javascript Client
So, a small biography...
I personally don't like to use librarys because I'm in the learning
stages of programming and I don't like to Learn function names
specific to a certian library when I could learn functions in the
actual language and get creative with them
so when I'm doing this without any Framework or AJAX or jQuery or
whatever....

anyway...

Heres my code

function verify()
{
// 0 Object is not initialized
// 1 Loading object is loading data
// 2 Loaded object has loaded data
// 3 Data from object can be worked with
// 4 Object completely initialized
if (xmlDoc.readyState != 4)
{
return false;
}
}

function requesting(location) {

if (window.XMLHttpRequest){xhttp=new XMLHttpRequest();}
else { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); }

xhttp.onreadystatechange=verify;
xhttp.open("GET",location,false);
xhttp.send(null);
return xhttp.responseXML;
}


Now, this works fine with XML on my server... but when I try to get
things from google like...

var starter = "http://gdata.youtube.com/feeds/api/users/";
var ender = "&key=devkeyyousillygooses"

function loaduzerz(){
var xmlDoc = requesting(starter+"FightClubVG/subscriptions?
v=2"+ender);
var elvid=xmlDoc.getElementsByTagName("feed")[0].getElementsByTagName
("entry");
var tooser;
for(x in elvid){
alert(elvid[x].getElementsByTagName("yt:username")[0].childNodes
[0].nodeValue);
}
}


I get a "Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101"

I don't understand what I'm doing wrong : /

monsur

unread,
Jan 20, 2010, 1:56:59 PM1/20/10
to Google Data Javascript Client
The issue is that XmlHttpRequests only work on the same domain (i.e.
from your server to your server). It won't work across domains (i.e.
from your server to YouTube's server). For that reason, you should
consider using the GData JavaScript Client for interacting with
Google's APIs. It has some workarounds to make communication across
domains work properly.

Thanks,
Monsur

Peacemaker

unread,
Jan 20, 2010, 5:28:36 PM1/20/10
to Google Data Javascript Client
But that makes me go against my own ideas lol
I'm just messing around, I don't mind using a library and GData but
its not what I prefer

At least I know XMLHTTPRequest's don't work cross domain
I'm going to see if I can just take out the functions from the google
API because I don't want to have to mess with it

I appreciate the response

Peacemaker

unread,
Jan 20, 2010, 7:06:09 PM1/20/10
to Google Data Javascript Client
Hm... I can't find it... If I do, I'll post it here

Robert Kluin

unread,
Jan 20, 2010, 9:39:32 PM1/20/10
to google-data-ja...@googlegroups.com
What you are trying to do is basically cross-site scripting (XSS).
One possible way to get around this is by using javascript to create
a new element on the page that will load the desired contents. But it
all depends on the application and the services you are interacting
with.

A google for "javascript cross-site ajax" should turn up several
possible solutions for you to try.

Robert

> --
> You received this message because you are subscribed to the Google Groups "Google Data Javascript Client" group.
> To post to this group, send email to google-data-ja...@googlegroups.com.
> To unsubscribe from this group, send email to google-data-javascri...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-data-javascript-client?hl=en.
>
>
>
>

Peacemaker

unread,
Jan 20, 2010, 10:05:32 PM1/20/10
to Google Data Javascript Client
Yeah, I saw Ajax.
But again, I don't want to start using Tons of different Libraries...
But I did find out it can just be done in PHP which is no issue for me
http://developer.yahoo.com/javascript/samples/proxy/php_proxy_simple.txt

And then being able to assign the variable can be done through this
http://www.webmaster-talk.com/php-forum/20054-how-do-i-assign-javascript-variable.html

I want to be getting as nitty gritty as I can without getting too
intimidated
I think This is a great start to start calling PHP functions through
Javascript since I've done that sort of thing before and I already
need to make a Post Request with php so it saves a lot of work : )

I appreciate the help though, many coding forums are silent when it
comes to things like this,
I'm happy that someone was able to give me feedback

:D

Peacemaker

unread,
Jan 22, 2010, 1:16:42 AM1/22/10
to Google Data Javascript Client
I'm going to try to do this is PHP, but thank you everyone for your
help :)

On Jan 20, 10:05 pm, Peacemaker <samto...@gmail.com> wrote:
> Yeah, I saw Ajax.
> But again, I don't want to start using Tons of different Libraries...

> But I did find out it can just be done in PHP which is no issue for mehttp://developer.yahoo.com/javascript/samples/proxy/php_proxy_simple.txt
>
> And then being able to assign the variable can be done through thishttp://www.webmaster-talk.com/php-forum/20054-how-do-i-assign-javascr...

Reply all
Reply to author
Forward
0 new messages