OPTIONEN 405 (Methode Nicht Erlaubt)

So, ich bin versucht, eine Fortschrittsanzeige beim hochladen von Dateien auf meine Website. Wenn ich laden Sie einfach die Ressource

$.ajax({
    url: $rootScope.URL,  //Server script to process data
    type: 'POST',
    beforeSend: beforeSendHandler,
    success: completeHandler,
    error: errorHandler,
    data: formData,
    cache: false,
    contentType: false,
    processData: false
});

Funktioniert es tadellos, aber wenn ich Falle, hören Sie Fortschritte:

$.ajax({
    url: $rootScope.URL,  //Server script to process data
    type: 'POST',
    xhr: function() {  //Custom XMLHttpRequest
        var myXhr = $.ajaxSettings.xhr();
        if(myXhr.upload){ //Check if upload property exists
            myXhr.upload.addEventListener('progress',progressHandlingFunction, false); //For handling the progress of the upload
        }
        return myXhr;
    },
    beforeSend: beforeSendHandler,
    success: completeHandler,
    error: errorHandler,
    data: formData,
    cache: false,
    contentType: false,
    processData: false
});

Bekomme ich:

OPTIONS myserver.com/controller/filtercontroller.php? 405 (Method Not Allowed)
  jQuery.ajaxTransport.send 
  jQuery.extend.ajax    
  (anonymous function)  
  jQuery.event.dispatch 
  jQuery.event.add.elemData.handle  
XMLHttpRequest cannot load myserver.com/controller/filtercontroller.php?. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342' is therefore not allowed access. The response had HTTP status code 405.

So offensichtlich mein server nicht Access-Control-Allow-Origin und OPTIONS Recht? Aber die obersten 2 Zeilen von filtercontroller.php sind:

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');

Ich habe versucht, mehrere unterschiedliche Lösungen, und keiner hat für mich gearbeitet.

Access-Control-Allow-Header können nicht zulassen, * als akzeptierte Wert, je nach dem server/client-Implementierung - stackoverflow.com/a/8719346/2155068
405 ist in der Regel ausgestellt durch den web-server selbst. So könnten Sie überprüfen Sie die Konfiguration Ihres web-Servers.
das ist irrelevant in diesem Fall-Access-Control-Allow-Origin: * " ist das ein akzeptabler Wert.
Nur um zu bestätigen-es gibt buchstäblich nichts anderes auf der Oberseite der, dass php-script, richtig? Es ist buchstäblich <?php und die beiden Funktionsaufrufe?
Ja, die ersten Zeilen der Datei sind <?php header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST, OPTIONS');

InformationsquelleAutor user3194367 | 2015-06-01

Schreibe einen Kommentar