2016-08-24 28 views
0

這裏是我的Ajax調用請求數據,以Ajax調用轉換爲JS對象

$.ajax({ 
    url:'http://localhost:8081/organizations/', 
    data: JSON.stringify({"name":"karthik"}), 
    type: 'POST', 
    dataType :'json', 
    processData : true, 

    success: (function(response){ alert("response "+response);}), 
    error: (function(err){ console.log(err); }) 
}); 

在API中,當我試圖打印request.data,爲什麼我收到這樣{u'{"name":"karthik"}': [u'']}

+0

閱讀此問題應該可以幫到你。 http://stackoverflow.com/questions/17785592/difference-between-json-stringify-and-json-parse –

回答

0

更換下面線

success: (function(response){ alert("response "+response);}), 

通過newone

success: (function(response){ alert(JSON.stringify(response));}), 

在你的代碼,然後嘗試它會工作。