How to send ajax request [POST] from Angular 2 to PHP?
<p>I'm getting frustrated since I've been trying my best to accomplish this kind of problem, searching for documentation and searching for possible duplicate question.</p>

<p>I've read this documentation <a href="https://angular.io/docs/ts/latest/guide/server-communication.html" rel="nofollow">https://angular.io/docs/ts/latest/guide/server-communication.html</a> but this doesn't have an example of posting data with PHP.</p>

<p>What I want to do is to check the database if it has a transaction that hasn't been approve. It runs every 3 seconds.</p>

<p>Here's what I've got</p>

<p>I created my Service [<code>get-new-data.service.ts</code>]</p>

<pre><code>import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http';
import 'rxjs/Rx';

@Injectable()
export class GetNewDataService {
    constructor(private http: Http) { }
    private url = 'app/service/getDataService.php';

    getData(bangko) {
        let headers = new Headers('Content-Type', 'application/x-www-form-urlencoded'),
            options = new RequestOptions({ headers: headers }),
            bank = `bank=${bangko}`;

        return this.http.post(this.url, bank, options).map(res =&gt; res.json());
    }
}
</code></pre>

<p>On my <code>app.module.ts</code>, I imported the HttpModule - imports and GetNewDataService - providers.</p>

<p>On my component</p>

<pre><code>import { Component, OnInit } from '@angular/core';
import { GetNewDataService } from '../service/get-new-data.service';
import { Observable } from 'rxjs/Rx';

@Component({
    templateUrl: 'app/tpl-html/mandiri.component.html'
})

export class MandiriComponent implements OnInit {
    constructor(private getDataService: GetNewDataService) { }

    ngOnInit() {
        setInterval(() =&gt; {
            this.getDataService.getData('mandiri')
                .subscribe(res =&gt; console.log(res));
        }, 3000)
    }
}
</code></pre>

<p>I don't know how to make proper request and integrate my angular 2 app with mysql and php.</p>

<p>Any help would be appreciated. Thanks :/</p>