我正在按照本教程尝试 DolphinDB 提供的 JSON API 。我尝试了这样的代码片段:
var code = "1+2";
code = encodeURIComponent(code);
paramJson = {
"sessionID": "942605602",
"functionName": "executeCode",
"params": [{
"name": "script",
"form": "scalar",
"type": "string",
"value": code
}]
}
var option = {
url: "http://localhost:9920",
async: true,
data: paramJson,
type: "POST",
dataType: "json",
success: function (data) {
var resultJson = data;
console.log(data);
}
}
$.ajax(option);
这是我从 chrome 获得的日志:
{sessionID: "800870454", userId: "", resultCode: "1", msg: "not a valid json request [sessionID=942605602&func…type%5D=string¶ms%5B0%5D%5Bvalue%5D=1%252B2].", object: Array(0)}msg: "not a valid json request [sessionID=942605602&functionName=executeCode¶ms%5B0%5D%5Bname%5D=script¶ms%5B0%5D%5Bform%5D=scalar¶ms%5B0%5D%5Btype%5D=string¶ms%5B0%5D%5Bvalue%5D=1%252B2]."object: []resultCode: "1"sessionID: "800870454"userId: ""__proto__: Object
它报告not a valid json request
,但我不知道我的请求有什么问题。