Results 1 to 2 of 2

Thread: XMLHttpRequest Problem

  1. #1
    Join Date
    Apr 2008
    Posts
    151

    XMLHttpRequest Problem

    I'm trying to create a script that will call a flickr rest method and output its XML. I have written the following code, but it seems to not work. I am stumped, and was wondering what I am doing wrong.

    I have uploaded my code to http://www.sfu.ca/~jca41/stuph/blahh/example.html


    Code:
    function foo() {
    	//var url = "http://flickr.com/services/rest/?method=flickr.photos.geo.getLocation&api_key=aa9b622e629e51d3fcda1f967c429237&photo_id=6174355034";
    	alert(loadXMLDoc(url));
    }
    
    function loadXMLDoc(dname) {
    	if (window.XMLHttpRequest) {
    		xhttp=new XMLHttpRequest();
    	} else {
    		xhttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	xhttp.open("GET",dname,false);
    	xhttp.send("");
    	return xhttp.responseText;
    }
    </script>

  2. #2
    Join Date
    Sep 2011
    Location
    London, UK
    Posts
    60
    XMLHttpRequest won't let you access resources on other domains than your. In order for this to work, you need a php script that fetches flickr url and XMLHttpRequest will request the file on your domain.

    flickr.php
    PHP Code:
    echo file_get_content('http://flickr.com/services/.....'); 
    flickr.html
    HTML Code:
    var url = "flickr.php";

Similar Threads

  1. Ajax XMLHTTPRequest Issue
    By inplaytoday in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 04 Apr 2011, 02:56 AM
  2. site upload problem big problem!!
    By monkeyboi in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 15 Jun 2010, 02:03 PM
  3. Replies: 1
    Last Post: 15 Mar 2010, 10:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •