首先在前台页面中的json数据为
在django的view中获取
var recipe = {};
recipe["name"] = $("#name").val();
recipe["age"] = $("#age").val();
recipe["sex"] = $("#sex").val();
recipe["medicine"] = "{'name': 'a', 'value': 'b'}";
使用ajax的post进行传输
$.ajax({
type: "post",
dataType: "json",
url: "/doctor/recipe/add/",
data: recipe,
success: function(Data){
alert("success")
}
});
在django的view中获取
request.POST中的数据为
能够发现medicine下的数据为字符串,可是是unciode格式