I am creating a safari extension and in the backend I am using python to save the data. But I am unable to call the python function, it is giving me this error:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
This is my python function url:http://localhost:8000/polls/add
I am using jquery/ajax to call the python function
This is my script code:
var action_url ="localhost:8000/polls/add";
params = 'contact_name=abc&contact_email=abc@gmail.com&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); }
});