When I post data through Angular 2, I'm getting this error in Chrome as well as Mozilla. Can anyone help me out?
Asked
Active
Viewed 86 times
-3
-
Welcome to _StackOverflow_! Here, you can learn [How to Ask](http://stackoverflow.com/help/how-to-ask) properly before you do so. When asking a question, be sure you are [on topic](http://stackoverflow.com/help/on-topic) and always try to provide a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) when possible. – lealceldeiro Feb 23 '17 at 17:30
-
This scenario occurs when One server request to fetch data from another server. So you should add Allow-Origin header in response – Keval Pithva Feb 23 '17 at 17:35
-
Agree, but what if it not work , when i already added the Allow Origin Header in my php file? – Swetanshu Sekhar Dubey Feb 23 '17 at 17:52
1 Answers
-1
A simple answer is that we need to add a Chrome or Mozilla extension to avoid this kind of error when posting data through jQuery AJAX or Angular 2 application using typescript.
We need to just copy the question and paste in google.com and include 'Extension for Chrome' or Mozilla.

Rory McCrossan
- 331,213
- 40
- 305
- 339
-
`A simple answer is , we need to add a chrome or mozila extension to avoid this kind of error`. That's a really bad solution. It relies on your users downloading a browser extension to be able to use your site correctly. No one is going to do that. A much better solution would be to either send your server response with the correct headers for cross-domain requests, or make the request server side. – Rory McCrossan Feb 23 '17 at 17:35
-
I'd also suggest you delete this question as it has been asked and answered much more effectively literally thousands of times before. – Rory McCrossan Feb 23 '17 at 17:35
-
But what if i have already added header(""Access-Control-Allow-Origin","*") in my php file, since the error is same. – Swetanshu Sekhar Dubey Feb 23 '17 at 17:38
-
Then you most likely have another error in the console which you should investigate. If it's a site you control, check you've also set the correct `Access-Control-Allow-Headers`. If it's not your site, then there's nothing you can do except send the request server side. As I mentioned, using an extension means that every person who browses your site needs to use that extension - not just you, hence why it is not a workable fix. – Rory McCrossan Feb 23 '17 at 17:39
-
I answer , like this because the same code is working in another computer, with perfect response, but not working on my computer, – Swetanshu Sekhar Dubey Feb 23 '17 at 17:42
-
-
My point too, but when i installed the extention cros, it was started working – Swetanshu Sekhar Dubey Feb 23 '17 at 17:48
-
Right - it works *for you but no one else who visits your site* – Rory McCrossan Feb 23 '17 at 17:48
-
That's why i suggest this answer because it may be the problem of current chrome. – Swetanshu Sekhar Dubey Feb 23 '17 at 17:49
-
One more thing i want to add is, this problem is only happening when i work in local machine , once it live, there is no issue. – Swetanshu Sekhar Dubey Feb 23 '17 at 17:50
-
we can also follow this link for more clarification :: ,http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource?noredirect=1&lq=1 – Swetanshu Sekhar Dubey Feb 23 '17 at 17:59
-
I know - that's the question I already marked as a duplicate :) – Rory McCrossan Feb 23 '17 at 18:05
-
-
You literally just said in your previous comment that the link gave more clarification...? I think I'm done. I still suggest you delete this question. Best of luck. – Rory McCrossan Feb 23 '17 at 18:59