469,270 Members | 1,764 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

XMLHttpRequest.open Permission Denied

Can someone please tell me why I get a "Permission denied to call method XMLHttpRequest.open" error? Here is my script:

Expand|Select|Wrap|Line Numbers
  1. var xmlHttp
  2.  
  3. function runSearch(element){
  4.     xmlHttp=GetXmlHttpObject();
  5.  
  6.     if( xmlHttp == null ){
  7.         alert("I think it is time to upgrade your browser");
  8.         return;
  9.     }
  10.  
  11.      var url = 'http://search.yahooapis.com/WebSearchService/V1/webSearch?';
  12.              url += 'appid=EKQTGpvV34GFx1J7y44QjPRfmvGmAAYKSdY3oUHcWH7Dgg6wsUNoxWaBU4_uf.lSjo0-';
  13.              url += '&results=20';
  14.              url += '&site=www.espn.com';
  15.              url += '&output=json';
  16.              url += '&query=' + element
  17.              url += '&callback=' + callback;
  18.     try{
  19.         xmlHttp.onreadystatechange = callback;
  20.         xmlHttp.open("GET", url, true);
  21.         xmlHttp.send(null);
  22.     }
  23.     catch(e){
  24.         alert(e);
  25.     }
  26. }
  27.  
  28. function callback(jsonObject){
  29.     alert(jsonObject.ResultSet.totalResultsAvailable);
  30. }
  31. function GetXmlHttpObject()
  32. {
  33. var xmlHttp=null;
  34. try
  35.   {
  36.   // Firefox, Opera 8.0+, Safari
  37.   xmlHttp=new XMLHttpRequest();
  38.   }
  39. catch (e)
  40.   {
  41.   // Internet Explorer
  42.   try
  43.     {
  44.     xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  45.     }
  46.   catch (e)
  47.     {
  48.     xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  49.     }
  50.   }
  51. return xmlHttp;
  52. }
  53.  
Thank you for your help
Oct 7 '07 #1
2 3497
acoder
16,027 Expert Mod 8TB
It's from a different domain. Let your server-side script make the cross-domain request and return the result. Use Ajax to make the request to the script on your own domain.
Oct 7 '07 #2
pbmods
5,821 Expert 4TB
Heya, Johhny.

Please use CODE tags when posting source code:

[CODE=javascript]
JavaScript code goes here.
[/CODE]
Oct 7 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by K | last post: by
1 post views Thread by vikas.khengare | last post: by
1 post views Thread by shotokan99 | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.