【问题标题】:Using a response from server to output in html [duplicate]使用来自服务器的响应以 html 输出 [重复]
【发布时间】:2018-09-04 11:05:54
【问题描述】:

我对 HTML 完全陌生,我想知道如何使用从服务器返回的 json 输出到 html 文件中。

更具体地说,我有一个 python 脚本,在执行时会给我一个 json 对象作为响应。我想通过浏览器将其打印在 html 文件中。我该怎么做?

我是否编写我的 html 以某种方式启动我的脚本并捕获对象?

【问题讨论】:

    标签: python html json


    【解决方案1】:

    例如,您可以浏览此代码,您可以在 sweetalert 中显示来自服务器的响应 组件:

        subscription(subscriptionEmail: Object) {
        this.contactusService.newsLetterData(subscriptionEmail).subscribe(res => {
          console.log(res);
          swal({
            title: res['Message'],
            type: 'success'
          });
          this.router.navigate(['home']);
    
        });
      }
    

    服务:

         newsLetterData(  newsLetter: {}): Observable<boolean> {
    
        return this.http.post<any>(AUTHURL + '/PageSlammer/newsLetter',  { newsLetter})
          .pipe(
            map(result => {
    
              //  localStorage.setItem('loggdIn', 'true');
              return result;
            }),
          );
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-24
      • 2019-07-06
      • 2011-01-26
      • 2021-07-22
      • 2023-04-11
      • 2021-04-15
      • 1970-01-01
      相关资源
      最近更新 更多