javascript - Crossdomain in python flask won't work -


i trying start communication between flask server , html page. included crossdomain code explained here http://flask.pocoo.org/snippets/56/ , still won't work. here python code:

from flask import * crossdomain import * app = flask(__name__) @app.route('/') @crossdomain(origin='*') def pocetna():     return '1' if __name__ == '__main__':     app.run(host='0.0.0.0',port=8081,debug=true)         

and here javascript:

function prebaci(){     var xmlhttp;     xmlhttp=new xmlhttprequest();     xmlhttp.onreadystatechange=function()     {          if (xmlhttp.readystate==4 && xmlhttp.status==200)          {              if (xmlhttp.responsetext==1) document.getelementbyid("kuca").innerhtml="radi";              else document.getelementbyid("kuca").innerhtml="ne radi";          }     }     xmlhttp.open("get","127.0.0.1:8081",true);     xmlhttp.send(); } 

in google chrome error is:

xmlhttprequest cannot load %3127.0.0.1:8081. cross origin requests supported http. 

and in mozzila firefox:

ns_error_dom_bad_uri: access restricted uri denied  

note specific error message, telling you not connecting http server; @ least chrome doesn't think so.

use:

xmlhttp.open("get","http://127.0.0.1:8081/",true); 

e.g. use qualified url.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -