Ich erstelle eine cordova-appache-Anwendung, wo ich mit einem Webserver kommunizieren (http und HTTP-Anfrage zu http://192.168.1.1/cgi/json/ ****) in meinem Code Javascript Ich benutze xhr, wenn ich die erste Anfrage senden, antworte der Server mir mit JSON Antwort und gebe mir eine Session ID und ich folge Antwort mit wireshark, das erste Problem http.status zurück 0 das zweite Problem in der Konsole log i diese Nachricht hatte Reason: CORS header 'Access-Control-Allow-Origin' missing.
CORS-Header 'Access-Control-Allow-Origin' fehlt Cordova
ich dies in config.xml hinzugefügt
<allow-navigation href="http://*/*"/>
<allow-navigation href="https://*/*"/>
<allow-navigation href="data:*"/>
Und dies Javascript-Code:
http.open('GET', request_field, true);
http.setRequestHeader("Access-Control-Allow-Origin", "*");
http.setRequestHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
http.setRequestHeader("Access-Control-Allow-Methods","POST, GET, OPTIONS, DELETE, PUT, HEAD");
http.send();
wie Umwelt ich verwende: ubuntu cordova Version: 6.1.1 NodeJS Version: v0.10.25 und Firefox
' ' in 'config.xml' –
Rayon
getan, aber funktioniert nicht !!! – mntsr
Senden Sie Header von Ihrem 'Webservice'? – Rayon