7dr3am7
7dr3am7

Reputation: 765

Dojo Reading file through xhrGet

I am trying to run an xhrGet like this one:

dojo.provide("test"); 

dojo.declare("test",null,{ 

getVersion: function(){ 
details = 
{ 
    url: "../version.txt", 

    content: "test", 

    handleAs: "text", 

    timeout: 4000, 

    load: function(data) 
    { 
            console.log("result" + data); 
    }, 

    error: function(error) 
    { 
            console.log("Error" + error); 
    } 
} 

var dfd = dojo.xhrGet(details); 
return dfd; 

});

and I am getting this error:

Error: Deferred Cancelled: [Exception... "Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIXMLHttpRequest.send]" nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)" location: "JS frame :: file:///C:/Dojo1.4.3/dojo/_base/_loader/bootstrap.js :: anonymous :: line 1351" data: no] file:///C:/Dojo1.4.3/dojo/_base/_loader/bootstrap.js Line 0

The file I am trying to retrieve is relative to dojo, therefore is located under Dojo1.4.3/version.txt

Other note.... I am not running it on a server, I am simply loading the html file with reference to the dojo class I have created.

thank you all for your time

EDIT

SOLUTION

I found the solution

https://developer.mozilla.org/en/Same-origin_policy_for_file%3a_URIs

you need to enable this policy in Firefox

Upvotes: 0

Views: 830

Answers (1)

hugomg
hugomg

Reputation: 69944

You cannot do AJAX requests if your page is being served directly via file://, for security reasons or something like that. You will need to set up a HTTP server and serve your page via that.

Also, is there any particular reason why you are using an old version of Dojo here? The current version is 1.7

Upvotes: 4

Related Questions