CouchDB更新处理程序赢得';不能正确添加
首先,我已经阅读并采纳了该问题答案中的准则 我有一个更新处理程序,它接受一个查询字符串金额,并应该将其添加到给定文档的doc.count中。它没有将这两个金额相加,而是列出了它们。例如,5+5=55。 同时,将parseInt()添加到doc.count会产生一条错误消息:CouchDB更新处理程序赢得';不能正确添加,couchdb,handler,Couchdb,Handler,首先,我已经阅读并采纳了该问题答案中的准则 我有一个更新处理程序,它接受一个查询字符串金额,并应该将其添加到给定文档的doc.count中。它没有将这两个金额相加,而是列出了它们。例如,5+5=55。 同时,将parseInt()添加到doc.count会产生一条错误消息: {"error":"render_error","reason":"undefined response from update function"} 我的更新处理程序是: countPlus:“函数(doc,req){v
{"error":"render_error","reason":"undefined response from update function"}
我的更新处理程序是:
countPlus:“函数(doc,req){var amount1=doc.count;var amount2=parseInt(req.query.amount);doc.count=amount1+amount2;返回[doc,doc.count];}”
处理请求的js是:
if (count != null && count != NaN && count != 0) {
var currentCounter = $.ajax({
type: "POST",
async: false,
url: $(location).attr("href").replace("_show/action", "_update/countPlus") + "?amount=" + count,
contentType : "application/json",
dataType: "json"
});
var currentCountResponse = currentCounter.responseText;
alert(currentCountResponse);
你的回答似乎是一个整数。也许你应该试着“严格化”它