2017-08-21 25 views
0

在後的人,我們有這個身體作爲原始數據 grant_type =密碼&用戶名=管理員&密碼=管理員如何在Ajax調用中傳遞原始數據?

我們如何寫在阿賈克斯同樣的事情?我們如何把它傳遞給數據參數Ajax的?

$.ajax({ 
    url : "/", 
    type: "POST", 
    **data: JSON.stringify([ 
     {id: 1, name: "Shahed"}, 
     {id: 2, name: "Hossain"} 
    ]),**--------> how do we pass above grant type here ? 
    contentType: "application/json; charset=utf-8", 
    dataType : "json", 
    success : function(){ 
     console.log("Pure jQuery Pure JS object"); 
    } 
}); 

回答

0

試試這個下面的代碼,

$.ajax({ 
    method  : "POST", 
    url  : "/", 
    dataType : "json", 
    data  : { grant_type: "password", username: "admin",password:"admin" } 
}) 
.done(function(msg) { 
    alert("Data Saved: " + msg); 
}); 
相關問題