On Tue, 12 Feb 2019 17:45:01 +0900, Nirav Patel wrote: > > [1 <multipart/related (7bit)>] > [1.1 <multipart/alternative (7bit)>] > [1.1.1 <text/plain; UTF-8 (7bit)>] > Hello > I am trying to send a GET request to RYU api > Server running RYU controller > http://192.168.52.142:8080/stats/switches > When i send this request from a web browser or through POSTMAN application > i get the response. > > But when i try to use a javaScript i get CORS error. > *Access to XMLHttpRequest at 'http://192.168.52.142:8080/stats/switches > <http://192.168.52.142:8080/stats/switches>' from origin 'null' has been > blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present > on the requested resource.* > > I am new to javascripting and I am unable to resolve this issue. I am > posting my Java script along with the headers that i receive in response. > Can someone help me resolve this issue/
I'm not quite familiar to javascript but AFAIK the CORS thing is to limit cross-site attacks. Maybe you put your javascript somewhere else than 192.168.52.142 or as a local file? > > function switchCount(){ > var xhttp = new XMLHttpRequest(); > xhttp.open("GET", "http://192.168.52.142:8080/stats/switches", true); > xhttp.send(); > //when xhttp state changes > xhttp.onreadystatechange = function() { > if (this.readyState == 4 && this.status == 200) { > // Typical action to be performed when the document is ready: > console.log('Request Successful'); > http_request.withCredentials = true; > document.getElementById("flowrule").innerHTML = xhttp.responseText; > } > }; > } -- IWAMOTO Toshihiro _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel