Couldn't ajax local file from local html page

前端 未结 2 464
逝去的感伤
逝去的感伤 2020-12-07 06:26

According to Same Origin Policy, SOP shouldn\'t apply to file:// protocol, but why my code does not work? I am running this testing page from my local system and I have abc.

相关标签:
2条回答
  • 2020-12-07 06:56

    This is not a bug, it's a security feature which you can't/won't get around on a client's computer.

    In chrome you can disable it by adding the following flag on the command line

    --disable-web-security

    Firefox might have something similar but I don't know it. This is only useful for development purposes and you can't rely on this behaviour in your application.

    You should really just use a server ...

    0 讨论(0)
  • 2020-12-07 07:02

    A slightly safer command line flag than ''--disable-web-security'' is

    --allow-file-access-from-files
    

    This does not completely turn off all security features. Still also this flag should not be used in productive environments...

    0 讨论(0)
提交回复
热议问题