【问题标题】:Ionic 2 App - Not making any Ajax calls via IOS SimulatorIonic 2 App - 不通过 IOS 模拟器进行任何 Ajax 调用
【发布时间】:2016-07-30 00:30:48
【问题描述】:

我一直在尝试通过模拟器运行这个应用程序。

当我运行 ionic emulate ios 时,此应用不会进行任何 Ajax 调用

当我运行 ionic emulate ios -c -l 时,此应用运行良好

这是我的提供程序类,我几乎完全从 Ionic 会议应用程序中复制了它

import {Injectable} from 'angular2/core';
import {Http, Headers} from 'angular2/http';
import 'rxjs/add/operator/map';
import {Storage,SqlStorage} from 'ionic-framework/ionic';

/*
  Generated class for the RafitoData provider.

  See https://angular.io/docs/ts/latest/guide/dependency-injection.html
  for more info on providers and Angular 2 DI.
*/
@Injectable()
export class RafitoData {
  static get parameters() {
    return [[Http]];
  } 
  constructor(http) {
    this.http = http;
    this.districts = null;
    this.storage = new Storage(SqlStorage);
  }


addCustomer(customer) {
    // don't have the data yet
    return new Promise(resolve => {

      var headers = new Headers();
      headers.append('Content-Type','application/json');

      var partialURL = '/rafitows/userInfo/create';
      var body = JSON.stringify(customer);
      // We're using Angular Http provider to request the data,
      // then on the response it'll map the JSON data to a parsed JS object.
      // Next we process the data and resolve the promise with the new data.
      this.http.post(partialURL,body,{headers:headers})
        .map(res => res.json())
        .subscribe(data => {
          resolve(data.status);
        }, err=> {console.log(err)});
    });
  }
}

我不确定我做错了什么。我有科尔多瓦白名单插件。

这是我的离子信息:

Cordova CLI: 5.4.0
Ionic Version: 2.0.0-beta.1
Ionic CLI Version: 2.0.0-beta.17
Ionic App Lib Version: 2.0.0-beta.8
ios-deploy version: Not installed
ios-sim version: 5.0.6 
OS: Mac OS X El Capitan
Node Version: v5.3.0
Xcode version: Xcode 7.2.1 Build version 7C1002

我已经把整个项目上传到了 gitHub

https://github.com/alyn000r/testAjax/tree/master/testAjax

【问题讨论】:

  • 调试器的错误日志中有哪些错误?

标签: ionic-framework ionic2


【解决方案1】:

请将下面的行添加到您的 config.xml

<allow-navigation href="*" />

也可以看看here

希望这对您有所帮助。谢谢。

【讨论】:

  • 我确实这样做了,这没有帮助:(
猜你喜欢
  • 2016-09-25
  • 2019-09-01
  • 2016-07-16
  • 1970-01-01
  • 1970-01-01
  • 2018-04-21
  • 2016-10-15
  • 2019-11-15
  • 1970-01-01
相关资源
最近更新 更多