0

I am trying to post data to my php page from angular2 . it generate correct url but when i use ajax call with same url it does not hit my php page.

let url = 'http://localhost/deals//wp-admin/admin-ajax.php?action=create&deal='+deal+'&price='+price; 
        console.log(url); // URL to web API
        var headers = new Headers();
        headers.append("Content-Type", "application/jsonp");
        return this._http.get(url, headers )
                    .map(res => res.json() );
  • Open the Console of your browser's developer tools. **Read the error message**. Expect to find that this is a [duplicate of this](http://stackoverflow.com/questions/35553500/xmlhttprequest-cannot-load-https-www-website-com/35553666#35553666). – Quentin Nov 08 '16 at 10:37
  • What on earth is `headers.append("Content-Type", "application/jsonp");` for? You are making a GET request, there is no request body to describe the content-type of. Even if there was, it wouldn't be `application/jsonp` since (a) JSONP formatted data is always a **response** and (b) the content type for JSONP is `application/javascript`. – Quentin Nov 08 '16 at 10:38

0 Answers0