title: Getting CORS origin error while ajax call in jQuery Data table
body: <p><strong>Here I put my code:</strong></p>
  <pre><code>var dataList = {    
      &quot;fromDate&quot;: &quot;2021-01-01&quot;,
      &quot;toDate&quot;: &quot;2021-01-16&quot;
  };
  
  var dataListNew = JSON.stringify(dataList);
  
  
  $('#co-table').DataTable({  
          //&quot;scrollY&quot;: &quot;400px&quot;,
           dom: 'Bfrtip',
           buttons: [
                      {
                          extend:    'copyHtml5',
                          text:      '&lt;i class=&quot;fa fa-files-o&quot;&gt;&lt;/i&gt;',
                          titleAttr: 'Copy'
                      },
                      {
                          extend:    'excelHtml5',
                          text:      '&lt;i class=&quot;fa fa-file-excel-o&quot;&gt;&lt;/i&gt;',
                          titleAttr: 'Excel'
                      },
                      {
                          extend:    'csvHtml5',
                          text:      '&lt;i class=&quot;fa fa-file-text-o&quot;&gt;&lt;/i&gt;',
                          titleAttr: 'CSV'
                      },
                      {
                          extend: 'pdfHtml5',
                          orientation: 'landscape',
                          //pageSize: 'LEGAL',
                          text:      '&lt;i class=&quot;fa fa-file-pdf-o&quot;&gt;&lt;/i&gt;',
                          titleAttr: 'PDF'
                      },
                      {
                          extend:    'print',
                          text:      '&lt;i class=&quot;fa fa-print&quot;&gt;&lt;/i&gt;',
                          titleAttr: 'Print'
                      }
                  ],                  
                              
          &quot;ajax&quot;: {
               url         : &quot;https://XXXXX.execute-api.us-east-1.amazonaws.com/XYXYX/YYY&quot;,
               method      : &quot;POST&quot;,
               dataType    : &quot;json&quot;,
               contentType : &quot;application/json; charset=utf-8&quot;,
               data        : dataListNew,
               headers    : {
                      &quot;authorizationToken&quot; :  authorizationToken,
                      &quot;Cache-Control&quot;      :  &quot;no-cache, no-store&quot;,
                      &quot;Content-Type&quot;       :  &quot;application/json; charset=utf-8&quot;,
                      &quot;x-api-key&quot;          :  applicationApiKey,
                      &quot;sciappID&quot;           :  appID,
                      &quot;sciappuserID&quot;       :  userID
              }
          },
          
          &quot;columns&quot;: [
              { &quot;data&quot;: &quot;PROCESSDATE&quot; },
              { &quot;data&quot;: &quot;MODELNAME&quot; },
              { &quot;data&quot;: &quot;MODELSTARTTIME&quot;, 
                  render: function (data, type, row)
                  {
                      if (data == null)
                      {
                          return '';
                      }
                      else
                      {
                          return moment(row.MODELSTARTTIME).format('YYYY-MM-DD HH:mm:ss');
                      }
                  }               
              },
              { &quot;data&quot;: &quot;MODELEXECUTIONSTATUS&quot; },
              { &quot;data&quot;: &quot;MODELENDTIME&quot;, 
                  render: function (data, type, row)
                  {
                      if (data == null)
                      {
                          return '';
                      }
                      else
                      {
                          return moment(row.MODELENDTIME).format('YYYY-MM-DD HH:mm:ss');
                      }
                  }                               
              },
              
              { 
                  &quot;data&quot;: &quot;RECORDCOUNT&quot;,
                  &quot;render&quot;: $.fn.dataTable.render.number( ',', '.', 0 )
              },
              { 
                  &quot;data&quot;: &quot;EXPORTEDCOUNT&quot;,
                  &quot;render&quot;: $.fn.dataTable.render.number( ',', '.', 0 ) 
              },
              { 
                  &quot;data&quot;: &quot;APPLIEDDECILE&quot;,
                  &quot;render&quot;: function ( data, type, row ) {
                              return data == 'N' ? '&lt;i class=&quot;fa fa-minus&quot;&gt;&lt;/i&gt;' : '&lt;i class=&quot;fa fa-check&quot;&gt;&lt;/i&gt;';
                          }
              },
              { 
                  &quot;data&quot;: &quot;ACTUALRECORDCOUNT&quot;,
                  &quot;render&quot;: $.fn.dataTable.render.number( ',', '.', 0 )
              },
              // { &quot;data&quot;: &quot;IS_SCHEMA_VALIDATED&quot; },
              { &quot;data&quot;: &quot;PROCESS_TYPE&quot; }
          ]       
      });
  </code></pre>
  <p><strong>Regarding CORS origin error getting in console:</strong></p>
  <blockquote>
  <p>(index):1 Access to XMLHttpRequest at 'https://xyxyxy.execute-api.us-east-1.amazonaws.com/v1/xxxx' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.</p>
  </blockquote>
  <p><strong>Request payload shows encoded:</strong>
  0=%7B&amp;1=%22&amp;2=f&amp;3=r&amp;4=o&amp;5=m&amp;6=D&amp;7=a&amp;8=t&amp;9=e&amp;10=%22&amp;11=%3A&amp;12=%22&amp;13=2&amp;14=0&amp;15=2&amp;16=1&amp;17=-&amp;18=0&amp;19=1&amp;20=-&amp;21=0&amp;22=1&amp;23=%22&amp;24=%2C&amp;25=%22&amp;26=t&amp;27=o&amp;28=D&amp;29=a&amp;30=t&amp;31=e&amp;32=%22&amp;33=%3A&amp;34=%22&amp;35=2&amp;36=0&amp;37=2&amp;38=1&amp;39=-&amp;40=0&amp;41=1&amp;42=-&amp;43=1&amp;44=6&amp;45=%22&amp;46=%2C&amp;47=%22&amp;48=p&amp;49=r&amp;50=o&amp;51=c&amp;52=e&amp;53=s&amp;54=s&amp;55=T&amp;56=y&amp;57=p&amp;58=e&amp;59=%22&amp;60=%3A&amp;61=%22&amp;62=%22&amp;63=%2C&amp;64=%22&amp;65=m&amp;66=o&amp;67=d&amp;68=e&amp;69=l&amp;70=N&amp;71=a&amp;72=m&amp;73=e&amp;74=%22&amp;75=%3A&amp;76=%22&amp;77=%22&amp;78=%2C&amp;79=%22&amp;80=s&amp;81=e&amp;82=a&amp;83=r&amp;84=c&amp;85=h&amp;86=L&amp;87=o&amp;88=g&amp;89=%22&amp;90=%3A&amp;91=%22&amp;92=%7B&amp;93=%5C&amp;94=%22&amp;95=a&amp;96=p&amp;97=p&amp;98=N&amp;99=a&amp;100=m&amp;101=e&amp;102=%5C&amp;103=%22&amp;104=%3A&amp;105=%5C&amp;106=%22&amp;107=c&amp;108=o&amp;109=x&amp;110=-&amp;111=m&amp;112=o&amp;113=d&amp;114=e&amp;115=l&amp;116=-&amp;117=f&amp;118=a&amp;119=c&amp;120=t&amp;121=o&amp;122=r&amp;123=y&amp;124=-&amp;125=d&amp;126=e&amp;127=v&amp;128=e&amp;129=l&amp;130=o&amp;131=p&amp;132=m&amp;133=e&amp;134=n&amp;135=t&amp;136=%5C&amp;137=%22&amp;138=%2C&amp;139=%5C&amp;140=%22&amp;141=a&amp;142=p&amp;143=p&amp;144=P&amp;145=a&amp;146=g&amp;147=e&amp;148=%5C&amp;149=%22&amp;150=%3A&amp;151=%5C&amp;152=%22&amp;153=m&amp;154=o&amp;155=d&amp;156=e&amp;157=l&amp;158=-&amp;159=m&amp;160=o&amp;161=d&amp;162=e&amp;163=l&amp;164=%5C&amp;165=%22&amp;166=%2C&amp;167=%5C&amp;168=%22&amp;169=a&amp;170=p&amp;171=p&amp;172=I&amp;173=D&amp;174=%5C&amp;175=%22&amp;176=%3A&amp;177=%5C&amp;178=%22&amp;179=%5C&amp;180=%22&amp;181=%2C&amp;182=%5C&amp;183=%22&amp;184=a&amp;185=u&amp;186=t&amp;187=h&amp;188=T&amp;189=y&amp;190=p&amp;191=e&amp;192=%5C&amp;193=%22&amp;194=%3A&amp;195=%5C&amp;196=%22&amp;197=g&amp;198=o&amp;199=o&amp;200=g&amp;201=l&amp;202=e&amp;203=%5C&amp;204=%22&amp;205=%2C&amp;206=%5C&amp;207=%22&amp;208=u&amp;209=s&amp;210=e&amp;211=r&amp;212=E&amp;213=m&amp;214=a&amp;215=i&amp;216=l&amp;217=%5C&amp;218=%22&amp;219=%3A&amp;220=%5C&amp;221=%22&amp;222=v&amp;223=i&amp;224=m&amp;225=a&amp;226=l&amp;227=r&amp;228=a&amp;229=j&amp;230=%40&amp;231=s&amp;232=c&amp;233=i&amp;234=e&amp;235=r&amp;236=a&amp;237=.&amp;238=c&amp;239=o&amp;240=m&amp;241=%5C&amp;242=%22&amp;243=%2C&amp;244=%5C&amp;245=%22&amp;246=u&amp;247=s&amp;248=e&amp;249=r&amp;250=I&amp;251=D&amp;252=%5C&amp;253=%22&amp;254=%3A&amp;255=%5C&amp;256=%22&amp;257=1&amp;258=0&amp;259=6&amp;260=3&amp;261=6&amp;262=6&amp;263=1&amp;264=1&amp;265=1&amp;266=4&amp;267=7&amp;268=3&amp;269=1&amp;270=2&amp;271=6&amp;272=3&amp;273=3&amp;274=5&amp;275=6&amp;276=0&amp;277=7&amp;278=%5C&amp;279=%22&amp;280=%2C&amp;281=%5C&amp;282=%22&amp;283=u&amp;284=s&amp;285=e&amp;286=r&amp;287=I&amp;288=P&amp;289=%5C&amp;290=%22&amp;291=%3A&amp;292=%5C&amp;293=%22&amp;294=%5C&amp;295=%22&amp;296=%7D&amp;297=%22&amp;298=%7D</p>