0

If the file is parallel to the loaded file , then able do ajax call and get the file data . Request is as like below

$.ajax({
    url:'test/file.html',
    type:'GET',
    dataType : 'text',
    crossDomain : true
})

But when the file is in other folder then unable get the data of that file with ajax call in local environment. Below code is unable to get the data from the passed url in MOZILLA. setted Access-Control-Allow-Origin in header , but still observing the issue.

$.ajaxSetup({
         headers : {
           'Access-Control-Allow-Origin' : '*'
         }
      });

 $.ajax({
    url:'../test/file.html',
    type:'GET',
    dataType : 'text',
    crossDomain : true
})

Any suggestions to overcome the issue from the scripting layer will be great.

Suresh
  • 923
  • 1
  • 10
  • 21
  • you shouldn't have cors problem if you are ajaxing to the same page – madalinivascu Feb 09 '17 at 08:08
  • Yea actually it should not but it is throwing NS_ERROR_DOM_BAD_URI: Access to restricted URI denied exception. Checked the url in command prompt . File is exist it has all read/write/execute permissions. – Suresh Feb 09 '17 at 08:09
  • Where are you getting the file from? Just the local file system, or a (local) web server? – Culme Feb 09 '17 at 08:14
  • By local file you mean file stored on client computer or file stored on the same server? In either case, why do you use cross-domain when it's local file? – Radek Pech Feb 09 '17 at 08:15
  • I think this may be your problem: http://stackoverflow.com/a/21856308/2011448 – Radek Pech Feb 09 '17 at 08:24
  • i am getting file form the local file system @Culme – Suresh Feb 09 '17 at 09:19
  • @RadekPech In browser i can't, Its not good to inform the users to change their browser settings , right?? i need to know how i can change in my custom written script.. – Suresh Feb 09 '17 at 09:23

0 Answers0