i want comunicate the views with backend from ajax, i am trying but not show in console the message of backend "HELLO", what is the problem?
<script type=text/javascript>
$(function() {
$('a#test').bind('click', function() {
$.getJSON('/background_process_test',
function(data) {
//do nothing
});
return false;
});
});
</script>
//button
<div class='container'>
<h3>Test</h3>
<form>
<a href=# id=test><button class='btn btn-default'>Test</button></a>
</form>
</div>
My backend is this, i am use framework flask
from flask import Flask, jsonify
from flask_cors import CORS, cross_origin
app = Flask(__name__)
CORS(app, support_credentials=True)
@app.route('/background_process_test')
@cross_origin(supports_credentials=True)
def background_process_test():
print "Hello"
return "nothing"
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8000, debug=True)
@app.route("/login")
@cross_origin(supports_credentials=True)
def login():
return jsonify({'success': 'ok'})
this error i get:
Access to XMLHttpRequest at 'file:///background_process_test' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.