[Solved] Access to XMLHttpRequest at ‘‘ from origin ‘null‘ has been bl

When AJAX is used, the above cross domain request error is reported (using Python flash to build the background)

Error code:

from flask import Flask,render_template
def getMarkdownLang():
    return render_template('result.html')

Solution: add a response header on the server side to simply allow cross source.

from flask import Flask,render_template,make_response
def getMarkdownLang():
    resp = make_response(render_template('result.html'))
    resp.headers['Access-Control-Allow-Origin'] = '*'   
    return resp

There are two other things that can go wrong:

    1. the requested path is not complete. Full path number/file path. Cross source must have full path. The request mode has no corresponding response code on the server side. For example, the server should have a post response for a post request

Read More: