2

i want to get json array return from http://graph.facebook.com/1mahalkita

 var xmlhttp = new XMLHttpRequest();
 xmlhttp.open("GET", "http://graph.facebook.com/1mahalkita", true); 
 xmlhttp.onreadystatechange = function() { 
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 
        alert(xmlhttp.responseText);
      } 
 } 
 xmlhttp.send();

this code should work but i'm getting error when i execute this code in firefox console
error

[Exception... "<no message>"  nsresult: "0x805e0006 (<unknown>)"  location: "JS frame :: debugger eval code :: <TOP_LEVEL> :: line 2"  data: no]

how can i fix this ? this is screenhot

enter image description here _________________________update____________________________________________________

actually code works on outher browser tab consoles .it only doesn't work when i execute from facebook tab.since i'm using this code with some other codes i have to use console on fb page code should execute in

Madhawa Priyashantha
  • 9,633
  • 7
  • 33
  • 60

1 Answers1

3

The problem is you're trying to load mixed content. You'll have to use https in the get request since Facebook only uses https.

Alexis Tyler
  • 1,394
  • 6
  • 30
  • 48
  • hmm but you can use http for graph api for example http://graph.facebook.com/100003102447840 however api has update recently now access token is required for this – Madhawa Priyashantha Sep 15 '15 at 09:13
  • You can access most pages on http, doesn't mean they'll work on https pages and that's what Facebook uses. That's the reason it doesn't work, http requests on https pages causes the mixed content warning. – Alexis Tyler Sep 15 '15 at 09:14
  • yes that could be the reason .but i'm not much understand deeper . – Madhawa Priyashantha Sep 15 '15 at 09:17
  • I'm not sure how else to explain it, hopefully this MDN page will help. https://developer.mozilla.org/en/docs/Security/MixedContent – Alexis Tyler Sep 15 '15 at 09:18