我需要模拟这个 curl 命令
curl -i -H "Accept: application/json" -H "Content-type:application/json" -X POST -d '{"username":"pippo","password":"secret123"}' http://url.org/api/login
通过jquery,我是这样制作的
$( document ).ready(function() {
$.ajax({
url:"http://urlapi/user/login",
type:"POST",
headers: {
"Accept" : "application/json; charset=utf-8",
"Content-Type": "application/json; charset=utf-8"
},
data:{ username: "pippo", password: "secret123" },
dataType:"json"
})
});
我仍然有内容类型的文本/html。这样对吗?