I have this python script, working correctly and returning a valid response:
import requests
import json
url = 'http://loremipsum.com'
data = '{"text": 'google'}'
r = requests.post(url,data=json.dumps(data))
response = r.text
print(response)
The issuse is with the JS code, it keep throwing this error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://loremipsum.com. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
$.ajax({
type: 'POST',
url: 'http://loremipsum.com',
data: '{"text": 'google'}',
crossOrigin: true,
success: function(data) { alert('result: ' + data); },
contentType: "application/json",
dataType: 'json'
});
I tried dataType: jsonp
Method not allowed by the server.