简体   繁体   English

Angular JS $ http.get()不适用于我的服务器,它可与localhost一起使用

[英]Angular JS $http.get() doesn't work with my server, it works with localhost tho

I have been working on ionic framework and coded in localhost 我一直在研究离子框架,并在本地主机中编码

$http.get(" http://localhost/mobile/user/addvoucher/ " + coupon + "/" + mid) $ http.get(“ http:// localhost / mobile / user / addvoucher / ” +优惠券+“ /” +中)

it is working fine in localhost. 它在本地主机工作正常。 However, when I change it to live. 但是,当我将其更改为可用时。 it doest work at all . 它根本不起作用。 I tested with the link on url or with postman . 我用url上的链接或邮递员进行了测试。 it working fine . 它工作正常。 It just not working at all when I connect with $http.get from my ionic frame 当我从离子支架连接$ http.get时,它根本无法工作

Any Suggestion is highly recommended. 强烈建议任何建议。 Can't see anything on firebug too . 也看不到萤火虫上的任何东西。

Thanks 谢谢

尝试删除“ http:// localhost ”,以便最终URL为

$http.get('/mobile/user/addvoucher/' + coupon + '/' + mid)

Thanks for suggestion . 感谢您的建议。 I found this as solution , Yes it is because of CORS issue . 我发现这是解决方案,是的,因为CORS问题。 So I included this on header of sever side php 所以我把它包含在服务器端php的标题中

header("Access-Control-Allow-Origin: *"); header(“ Access-Control-Allow-Origin:*”); header("Content-Type: application/json; charset=UTF-8"); header(“ Content-Type:application / json; charset = UTF-8”);

and it works .Found solution here 并且有效。在这里找到解决方案

http://www.w3schools.com/angular/angular_filters.asp http://www.w3schools.com/angular/angular_filters.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM