没有回应从角2 http.get到PHP文件
问题描述:
在我的角2 http.get中的东西是不正确的,但是,我不明白那是什么。没有回应从角2 http.get到PHP文件
我尝试从常规格式发送3个输入字段数据到ajax.php服务器文件,并通过echo命令提醒服务器的响应。这样我就可以确保沟通正常。虽然通信正常工作之间铬扩展程序与ajax.php服务器文件正确(有适当的JSON响应),我的角码在应用程序警报响应[对象对象]只。解析对象到数据不起作用。有时回复是空白的。这是我的角的代码: 第一个文件 - contact.component.ts,方法的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()
);
}
}
的反应应该是在浏览器作为JSON对象警报消息: {邮件:danielgontar @的Gmail .com}。铬扩展名正确显示来自服务器的响应。
答
您在您尝试获取URL的URL中放置了四个“wwww”。
this.http.get(的 'http:// WWWW .delikates.co.il/ajax.php名称=?' +名字+ '&电子邮件= '+电子邮件+' &移动=' +移动)
试试这个,这是我工作的检查:
return this.http.get('http://www.delikates.co.il/ajax.php?name='+name+'&email='+email+'&mobile='+mobile)
.subscribe((data:Response)=>data.json()
);
亲爱卡姆利什杰哈,感谢名单回答。我看到我的代码中有3个w。对不起,我不明白 –