2016-04-08 61 views
1

我一直試圖通過模擬器運行這個應用程序。Ionic 2應用程序 - 不通過IOS模擬器進行任何Ajax調用

當我運行離子模仿IOS,這個程序不會讓任何Ajax調用

當我運行離子模仿IOS -c -l這個應用程序完美的作品

這是我的供應商類我幾乎完全從離子會議應用複製

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

+0

調試器的錯誤日誌中有哪些錯誤? –

回答

0

請添加下面一行到你的config.xml

<allow-navigation href="*" /> 

也看看here

希望這可以幫助你。謝謝。

+0

我做到了這一點,這並沒有幫助:( – alyn000r

相關問題