1

With reference to this thread https://stackoverflow.com/questions/22627392/extjs-fileuplaod-cross-origin-frame

Can anyone tell me how to set the values when server side language is PHP. I need to get JSON data. I am using ExtJS at front end.

COMPLETE SCENARIO:

I have a code to upload a json file to server then get the content of this file as response, but after upload I am getting {success:false,message:"Blocked a frame with origin "http://localhost:1842" from accessing a cross-origin frame."} .

If there is any better solution to read a json file which is located on client computer it will also be helpful.

Code I am using is:

function(){
  var form = this.up('form').getForm();
  if(form.isValid()){
    form.submit({
      params: {
        domain: document.domain
      },
      url: 'http://MY-IP/phpfileupload/file.php',
      waitMsg: 'Graph Uploading',
      success: function(fp, action) {
    },
    failure: function(fp, action) {
    }
  });
}   }
Community
  • 1
  • 1
Girdhari Agrawal
  • 375
  • 3
  • 18

1 Answers1

1

You ran into the same origin policy, which is a security feature of javascript.

If you request something via javascript, it has to be:

  • the same host name including the sub domain
  • the same protocol
  • the same port

Otherwise you will get the exception above.

You can get around this:

  • use CORS which defines cross site access (this means you must have access to the foreign web service to add http header information)
  • or create a reverse proxy and make the foreign server appear as being on the same domain (this means you need access on the web server on your side)
  • or if you can, do the stuff on the same server right from the start
Kai Mattern
  • 3,090
  • 2
  • 34
  • 37