2016-10-04 39 views
0

當前代碼正在制定reactjs並用Axios公司與0.14.2版本執行所述AJAX請求:錯誤返回從PHP一個JSON與Axios公司以reactjs

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工作,並讓它連續運行,我所做的就是在ejeuctar的WebPack webpack.config.js控制檯和束產生.js和準備好的axios完美工作,並且還請求$ .ajax。