2016-10-04 7 views
0

でreactjsするPHPからJSONを返す:私は修正することができますように私は、プレーンテキストを返してエラーは、現在のコードがreactjsを働いたとバージョン0.14.2とaxiosでAJAXリクエストを実行しているaxios

componentWillMount(){ 

    const peticion = this; 
    const config = { 
         headers: {'X-Requested-With': 'XMLHttpRequest'}, 
         transformRequest: [function (data) { return data; }], 
         transformResponse: [function (data) { return data; }], 
         //responseType: 'json' 
        }; 

    axios.get('procesos/lista.php', config) 
    .then(function (r){ 

     console.log(r); 

     peticion.setState({ 
      datos:[r.data] | [] 
     }); 
    }) 
    .catch(function (error) { 
     console.log(error); 
    }); 
} 

それ。

テキストと、それをされて返さない:問題へ enter image description here

答えて

0

私のソリューションは、WebPACKのと協力し、それが継続的に実行できるようにした、私がやったことはWebPACKのwebpack.config.jsコンソールにejeuctarだったとバンドルを生成します.jsとready axiosは完璧に動作し、$ .ajaxも要求します。

関連する問題