jquery - How to pass Raw Data in Ajax call? -
in post man include in body raw data grant_type=password&username=admin&password=admin
how write same thing in ajax ?how pass data parameter of ajax ?
$.ajax({ url : "/", type: "post", **data: json.stringify([ {id: 1, name: "shahed"}, {id: 2, name: "hossain"} ]),**--------> how pass above grant type here ? contenttype: "application/json; charset=utf-8", datatype : "json", success : function(){ console.log("pure jquery pure js object"); } });
try below code,
$.ajax({ method : "post", url : "/", datatype : "json", data : { grant_type: "password", username: "admin",password:"admin" } }) .done(function( msg ) { alert( "data saved: " + msg ); });
Comments
Post a Comment