Ich arbeite an einer mobilen App. Ich brauche ein paar Daten von Wordpress-Website zu holen, aber die http
Anfrage immer durch Fehler Antwort für Preflight hat ungültige HTTP-Statuscode 403Ionic 3 HTTP-Post-Anfrage ungültiger HTTP-Status-Code 403, während jQuery Ajax Post funktioniert einwandfrei
Typoskript
this._http.post('http://www.example.com/wp-admin/admin-ajax.php',{
'action' : 'get_votes',
'postId' : 123456
})
.subscribe(data=>{
console.log(data);
},error=>{
console.log(error);
})
jQuery
Das gleiche funktioniert in jQuery auf dem lokalen Server
$.ajax({
url: 'http://www.example.com/wp-admin/admin-ajax.php',
type: 'post',
dataType: 'JSON',
data: {
'action': 'get_votes',
'postId': 123456
},
success: function(result) {
console.log(result);
},
error: function(error) {
console.log(error);
}
});
Die cordova-plugin-whitelist
ist bereits installiert.
config.xml
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
Ich habe das Plugin für Chrome bereits installiert. Auch der 'header ('Access-Control-Allow-Origin: *');' ist in der API enthalten. Ich weiß nicht, eckige 'http' funktioniert nicht. Aber dieses Plugin 'cordova-plugin-advanced-http' funktioniert einwandfrei. – shah