私はサファリ拡張を作成しており、バックエンドではデータを保存するためにpythonを使用しています。しかし、私はそれが私にこのエラーを与えている、Pythonの関数を呼び出すことができません:サファリ拡張からpython関数を呼び出す方法
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
これは私のpython関数のURLです:http://localhost:8000/polls/add
私は
Python関数を呼び出すためにjqueryの/ AJAXを使用していますこれは私のスクリプトコードです:
var action_url ="localhost:8000/polls/add";
params = 'contact_name=abc&[email protected]&content=here is content';
$.ajax({
url: action_url,
type: 'GET',
beforeSend: function(xhr){
xhr.setRequestHeader('Access-Control-Allow-Origin', 'localhost');
},
xhrFields: { withCredentials: true },
crossDomain: true,
data: JSON.stringify(params),
error: function (e) { alert('error = '+e) },
success: function (data) { alert(data); }
});
コメントを追加する代わりに質問を編集してください。 – GGG
こんにちはGGG、 ご返信ありがとうございます。 Ok、編集 – dev