首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >没有从http.get 2到php文件的响应

没有从http.get 2到php文件的响应
EN

Stack Overflow用户
提问于 2017-05-07 05:19:59
回答 1查看 461关注 0票数 1

在我的角度2 http.get是不正确的,然而,我不明白这是什么。

我试图从常规表单向ajax.php服务器文件发送3个输入字段数据,并通过echo命令从服务器发出警报。那样的话,我就能确定通信是有效的。虽然铬扩展程序与ajax.php服务器文件之间的通信是正确的(有正确的json响应),但我在应用程序中的角度代码只提醒响应对象。将对象解析为数据不起作用。有时反应是空白的。下面是我的角度代码:第一个文件- contact.component.ts,方法onSubmit():

代码语言:javascript
运行
复制
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对象在浏览器中处于警报消息:{mail:danielgontar@gmail.com}。chrome扩展正确地显示了来自服务器的响应。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-07 05:31:47

你已经从你想要得到的URL中输入了四个“www.w”。

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

试试看,我查过了,效果很好:

代码语言:javascript
运行
复制
 return this.http.get('http://www.delikates.co.il/ajax.php?name='+name+'&email='+email+'&mobile='+mobile)
        .subscribe((data:Response)=>data.json()
        );
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43828100

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档