Learn, Share, Build

October 05, 2017, at 2:35 PM

I am making a POST request to AWS s3 API gateway using JQUERY & AJAX. Upon submit, the shadow is updated. However I get an error in the console. Here is the ajax part of the code,

var myJSON = JSON.stringify(obj);
   type: "POST",
   url:  "<aws-url>" ,
   data: myJSON,
   crossDomain : true,
   //dataType: 'jsonp',
   headers :{
   success: function(result) {

The POST works and the shadow is updated, but I still get this error at the console. Also I am aware that postman can't be used with POST method. Here is the error: Failed to load :No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s3-ap-southeast-1.amazonaws.com' is therefore not allowed access.

I don't understand whats going on. Please help!!

Answer 1

Please enable CORS in you API gateway like below.

If you don't have OPTIONS added, please follow below steps (If OPTIONS already there just add CORS),

  • Create a new OPTIONS method under the /services resource
  • Create and populate the Access-Control-Allow-Origin/Method/Headers in the OPTIONS method.

Enable CORS like below after creating OPTIONS

Learn, Share, Build

Learn, Share, Build

I found this nice script, by Bitwise Creative, to change the color of a numeric content by the value

Learn, Share, Build

Learn, Share, Build

Please help meHow can I add a button in the following jQuery DataTable?

Learn, Share, Build

Learn, Share, Build

I have written following code for validation of date

Learn, Share, Build

Learn, Share, Build

I created a addEventListener and want to send the event to another function so it handles itBut i keep getting this error(on firefox browser):