How to load ace editor

后端 未结 4 1718
半阙折子戏
半阙折子戏 2021-02-12 22:17

I am trying to use the Ace code editor library (http://ace.ajax.org/), but im having trouble. According to the embedding guide, this should load the required js files from Amazo

4条回答
  •  死守一世寂寞
    2021-02-12 22:37

    I can't paste all the code in the comment, so I'll start to answer your question by updating this one. This works fine for me:

    
    
    
        
        HTML
        
    
    
        
    function foo(items) { var x = "All this is syntax highlighted"; return x; }

    Can you test this at your end and see if you still get the problems? If this code (singular) is ok it's probably that some other JavaScript affects ACE.

    Here's a JSfiddle: http://jsfiddle.net/yDscY/. I get no errors in my Development Inspector.

    I found the problem. If you have PHP or can do it with .htaccess. You have to send specific headers to comply to CORS (Cross Origin Resource Sharing).

    access-control-allow-origin: *
    access-control-allow-credentials: true
    

    After that it should work.

    Update

    I didn't test this part thoroughly, but it should work.

    
        Header set Access-Control-Allow-Origin "*"
        Header set Access-Control-Allow-Credentials: "true"
    
    

    Good luck!

提交回复
热议问题