2011/5/23 Tio Oscar <[email protected]> > 2011/5/23 Anton Kovalyov <[email protected]> > >> Assuming that you are not running this code from google.com, that error >> happens because of Same Origin Policy supported by all browsers. Basically >> it means.that you can't do cross-domain XmlHttpRequest calls. >> >> Anton >> On May 23, 2011 6:21 AM, "nasi" <[email protected]> wrote: >> > I am using the following code. when I run this code in eclipse it >> > works but when I want to run it in chrome I get "XMLHttpRequest cannot >> > load" error. >> > >> > var req = new XMLHttpRequest(); >> > req.open("get", 'http://www.google.com/search? >> > hl=enrlz=1I7SKPB_en&q=query'&start=10&sa=N target="blank"'/", true); >> > req.onreadystatechange = function(){ //instead of onreadystatechange >> > //do something >> > }; >> > req.send(null); >> > >> > I checked it with "req.onload" as well. but in that case it neither >> > runs in eclipse nor chrome. >> > >> > do you have any idea? >> > >> > Thanks >> > >> > -- >> > To view archived discussions from the original JSMentors Mailman list: >> http://www.mail-archive.com/[email protected]/ >> > >> > To search via a non-Google archive, visit here: >> http://www.mail-archive.com/[email protected]/ >> > >> > To unsubscribe from this group, send email to >> > [email protected] >> >> -- >> To view archived discussions from the original JSMentors Mailman list: >> http://www.mail-archive.com/[email protected]/ >> >> To search via a non-Google archive, visit here: >> http://www.mail-archive.com/[email protected]/ >> >> To unsubscribe from this group, send email to >> [email protected] >> > > You can emulate the cross-domain ajax calls, i do a class for that: > http://pastebin.com/m72Uwzy2, but the destiny need pass a js var " > CrossCall.responseBuffer". > For cross-domain ajax petitions (with out autorization of the other > domain), yo can do a proxy like script, ej: > > proxy.php > > $url = $_GET['url']; > > if (!preg_match('#^http[s]?://#i', $url)) { > throw new Exception ("Access denied"); > } > > $data = file_get_contents($_GET['url']): > > echo json_encode(array( > 'url' => $url, > 'content' = $data > )); > > and from JS: > > url = 'http://www.google.com/search?hl=enrlz=1I7SKPB_en&q=query'; > > req.open("get", '/proxy.php?url=' + escape(url), options , true); > > -- > El Tio ~ Programador, hacker y filósofo > web: http://blog.exodica.com.ar > Linked'in: http://www.linkedin.com/in/ogentilezza > Twitter: @exos <http://twitter.com/exos>, Indeti.ca: > @exos<http://identi.ca/exos> > Tels: [+54 11] 638-LINUX (54689) - [+54 9 11] 6799-4797 > > Mmmm. I aclare, in the case of google, has banned your IP before a lot of petitions.
But you can use the seach API: http://code.google.com/apis/customsearch/v1/overview.html -- El Tio ~ Programador, hacker y filósofo web: http://blog.exodica.com.ar Linked'in: http://www.linkedin.com/in/ogentilezza Twitter: @exos <http://twitter.com/exos>, Indeti.ca: @exos<http://identi.ca/exos> Tels: [+54 11] 638-LINUX (54689) - [+54 9 11] 6799-4797 -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
