質問

Mozillaの独自の仕様のこれまでの単純なGETまたはPOSTは、プリフライトなしでネイティブにCORSのでなければなりませんと言うが、私が作ったすべてのPOSTの試みが外出OPTIONSヘッダをもたらしました。私はコードを取得するためにPOSTからそれを変更すると、クロスサイト一部が正常に動作しているので、すぐに適切なGET要求を送信します。

ここで私はFirefoxでやっているのスリムダウンサンプルがあります:

 var destinationUrl = 'http://imaginarydevelopment.com/postURL';
 var invocation = new XMLHttpRequest();
            if (invocation) {
                invocation.open('POST', destinationUrl, true);
                //tried with and without this line
                //invocation.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

                invocation.onreadystatechange = (function Handler() {
                if (invocation.readyState == 4)
                        alert('Request made');
                });
                invocation.send(/* tried with and without data*/);
            }

ここで私はすでにChromeとIEで働いていたものです。

var destinationUrl = 'http://imaginarydevelopment.com/postURL';
var destination = { url: destinationUrl, type: 'POST', success: AjaxSuccess, error: AjaxError,
            dataType: 'text', contentType: 'application/x-www-form-urlencoded'
        };
  destination.data = { 'rows': rowList, 'token': token };
            $jq.ajax(destination);
役に立ちましたか?

解決 2

だけでなく、私はすべてのcontenttypesのは、実際に仕事かわからないけどtext/plainはすべての3つのブラウザでいます:

var destination = { url: destinationUrl, type: 'POST', success: AjaxSuccess, error: AjaxError,
             contentType: 'text/plain'
        };
var postData={ 'anArray': theArray, 'token': token };
            destination.data=JSON.stringify(postData);

$jq.ajax(destination);
しかし、これまでのところ、私は505のコードが返されても、成功の方法を実行している以外に何もしてからの要求を停止しているもの考え出したていません。 Access-Control-Allow-Origin: *の応答ヘッダを追加すると、戻りデータを読み取ることを望まないブラウザを解決します。

他のヒント

私は同じ問題を抱えている。

https://developer.mozilla.org/En/HTTP_Access_Controlする

のenctypeがtext / plainでなければならないと言うか、FX4 +を使用する必要があります すべてのアクセスのヘッダーが正しく設定する必要があります。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top