Loading a text file through AJAX gives restricted URI error

前端 未结 2 2118
天涯浪人
天涯浪人 2020-12-16 23:14

I mentioned i read the suggested link ...and Could not able to understand the suggestion ..\"Use Greasemonkey to modify Pages and start writing some javas

相关标签:
2条回答
  • 2020-12-16 23:27

    Browser security prevents the code from running. You are better off running a local server such as IIS or Apache.

    You can change your browser to run local content by changing a browser config

    Firefox

    1. Go to about:config
    2. Find security.fileuri.strict_origin_policy parameter
    3. Set it to false
    0 讨论(0)
  • 2020-12-16 23:54

    I finally seems to Get it working . Here is working Script

    $("button").click(function(){
        $.ajax({url:"http://localhost/demo_test.txt",success:function(result){
          $("#div1").html(result);
        }});
      });
    

    Workaround : put the html file and text file on local server (IIS) New Site .

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