[英]Unable to pass data from javascript to json
I want to pass data from hands on table to servlet . 我想将数据从动手表传递到servlet。 I have tried a method in which I am able to get the data when iItry to pass to servlet I am not able to get the data from
request.getParameter("forecastdata");
我尝试了一种方法,其中当iItry传递给servlet时我能够获取数据,而我无法从
request.getParameter("forecastdata");
获取数据request.getParameter("forecastdata");
which is null. 这是空的。 Please tell what is the mistake in my code ArrayToJson
请告诉我代码ArrayToJson中的错误是什么
@WebServlet("/arrayToJson/*")
public class ArrayToJson extends HttpServlet {
@Override
protected void doPost(final HttpServletRequest request,
final HttpServletResponse response) throws ServletException,
IOException {
StringBuffer jb = new StringBuffer();
String line = null;
request.getParameter("forecastdata");
;
}
}
JavaScript 的JavaScript
$("#divButtons").find(".btnSubmit").click(function () {
console.log($container.data('handsontable').getData());
var forecast=$container.data('handsontable').getData()
$.ajax({
url: "/Pj_IFRS_P5/arrayToJson",
data: {
forecastdata: forecast
}, //returns all cells' data
dataType: 'json',
type: 'POST',
success: function (data) {
if (data.result === 'ok') {
console.log('Data saved');
} else {
console.log('Save error');
}
},
error: function () {
console.log('Save error. POST method is not allowed on GitHub Pages. Run this example on your own server to see the success message.');
}
});
});
$("#handsontable").handsontable(config);
});
since you're using jquery you can check your condition and disable the row fully by using a filter. 由于您使用的是jquery,因此您可以检查条件并使用过滤器完全禁用该行。 there are lot of examples out there and even in stackoverflow .
有很多例子,甚至在stackoverflow中。
one example and fiddle is HERE 一个例子和小提琴是这里
if that is your case now, this might answer it ! 如果现在是您的情况,可能会回答!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.