1

Something in my angular 2 http.get is not correct, However, I don't understand what that is.

I try to send 3 input fields data, from regular form, to ajax.php server file, and alert the response from the server via echo command. That way I will be sure that the communication is working. while communication is working between chrome extension program with the ajax.php server file correctly (there is proper json response), my angular code in the app alerts response [object object] ONLY . parsing the object to data does not work. Sometimes the response is blank . here is my angular code : first file - contact.component.ts , method onSubmit() :

onSubmit(form:any)
    {
        this.name = form.value.name;
        this.email = form.value.email;
        this.mobile = form.value.mobile;
        /* ajax call*/
        alert(this.name+this.email+this.mobile);
     alert(this.authService.send_lead_information(this.name,this.email,this.mobile));
    }
    second file - auth.service.ts :

    import { Injectable } from '@angular/core';
    import {Http, Response} from "@angular/http";
    import any = jasmine.any;

    @Injectable()
    export class AuthService {
        constructor(private http:Http) {}

        send_lead_information(name,email,mobile)
        {
            return this.http.get('http://wwww.delikates.co.il/ajax.php?name='+name+'&email='+email+'&mobile='+mobile)
                .subscribe((data:Response)=>data.json()
                );
        }
    }

the response should be in alert message in the browser as a json object : {mail:[email protected]} . the chrome extension shows the response from the server correctly.

1 Answer 1

1

You have putted four no of "wwww" in the URL from where you are trying to GET.

this.http.get('http://wwww.delikates.co.il/ajax.php?name='+name+'&email='+email+'&mobile='+mobile)

Try This , It is working I checked:

 return this.http.get('http://www.delikates.co.il/ajax.php?name='+name+'&email='+email+'&mobile='+mobile)
        .subscribe((data:Response)=>data.json()
        );
Sign up to request clarification or add additional context in comments.

1 Comment

Dear Kamlesh Jha, Thanx for answering. I see that there are 3 w in my code. sorry i dont understand

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.