title: Response with status: 200 Ok for URL: null error for angular2.0 http post
body: <p>I am trying to post data using http in angular 2,i added a http call with added api to it and when i click the button it should post data to my db,in cosole it shows error</p>
  
  <pre><code>XMLHttpRequest cannot load http://localhost/a2server/index.php/profile/addprofile. 
  Request header field Content-Type is not allowed by Access-Control-  
  Allow-Headers in preflight response.
   EXCEPTION: Response with status: 200 Ok for URL: null
  
  
  
  import {Component} from '@angular/core';
  import {Http, Response, Headers} from '@angular/http';
  import {Observable} from 'rxjs/Observable';
   import {Subject } from 'rxjs/Subject';
  
    @Component({
  templateUrl: './components/http/http.html'
  })
  
  export class HttpSample {
  
  
  http: Http;
  
  postResponse = new Person();
  
  
  constructor(http: Http) {
  
      this.http = http;
  
  }
  
  
  
  onSubmit(){
  
      var headers = new Headers();
      headers.append('Content-Type', 'application/json');
       this.http.post('http://localhost/a2server/index.php/profile/addprofile', JSON.stringify({firstName:'Joe',lastName:'Smith'}),{headers:headers})
           .map((res: Response) =&gt; res.json())
           .subscribe((res:Person) =&gt; this.postResponse = res);
   }
   }class Person{
   firstName:string;
   lastName:string;
   }
  </code></pre>
  
  <p>and i am not posting any values from my view,just i place a button</p>
  
  <pre><code>  &lt;div&gt;
    &lt;button (click)="postData()"&gt;Post Data&lt;/button&gt;
  
  
  &lt;/div&gt;
  </code></pre>