Access-Control-Allow-Origin and Angular.js $http

前端 未结 7 1798
盖世英雄少女心
盖世英雄少女心 2020-12-24 06:37

Whenever I make a webapp and I get a CORS problem, I start making coffee. After screwing with it for a while I manage to get it working but this time it\'s not and I need he

相关标签:
7条回答
  • 2020-12-24 06:58

    Try with this:

              $.ajax({
                  type: 'POST',
                  url: URL,
                  defaultHeaders: {
                      'Content-Type': 'application/json',
                      "Access-Control-Allow-Origin": "*",
                      'Accept': 'application/json'
                   },
    
                  data: obj,
                  dataType: 'json',
                  success: function (response) {
                //    BindTableData();
                    console.log("success ");
                    alert(response);
                  },
                  error: function (xhr) {
                    console.log("error ");
                    console.log(xhr);
                  }
              });
    
    0 讨论(0)
提交回复
热议问题