douhai5835 2015-11-06 18:26
浏览 89

Cordova AngularJS $ http.post浏览器CORS问题 - 请求的资源上存在“No'Access-Control-Allow-Origin'标头。 起源”

Hope this helps someone else out there (as it took me hours to find a fix).

* Yes there are many duplicate similar questions out there, that are similar - But mine is specific to a Cordova platform Browser app. *

I am building an with AngularJS using Cordova/PhoneGap. I had a cross domain issue while making a AngularJS POST request ($http.post) to a PHP API. If was returning - "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin"

Please see answer below.

  • 写回答

1条回答 默认 最新

  • duanhan5388 2015-11-06 18:26
    关注

    I Had to add the following to the PHP API script:

    header('Access-Control-Allow-Origin: *');
    

    Now after doing an $http.post it will return status code 200!

    评论

报告相同问题?

悬赏问题

  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码