Javascript 如何通过ajax发送复选框值:true或false
我想使用ajax将复选框的值发送到数据库。通过互联网上的一些搜索,我不知何故做到了这一点。这就是我一直在使用的。我需要对json2.stringify进行哪些更改才能正确发送我的值 Html: 使用.prop“checked”属性Javascript 如何通过ajax发送复选框值:true或false,javascript,jquery,html,ajax,Javascript,Jquery,Html,Ajax,我想使用ajax将复选框的值发送到数据库。通过互联网上的一些搜索,我不知何故做到了这一点。这就是我一直在使用的。我需要对json2.stringify进行哪些更改才能正确发送我的值 Html: 使用.prop“checked”属性 <HTML> <input type="checkbox" id="txtCategoryIsPaid" name="cateogryIsPaid" value="Paid">Yes<br> Javascript AddCateg
<HTML>
<input type="checkbox" id="txtCategoryIsPaid" name="cateogryIsPaid" value="Paid">Yes<br>
Javascript
AddCategory: function () {
BusinessManagement.config.method = "AddBusinessCategory";
BusinessManagement.config.url = BusinessManagement.config.baseURL + BusinessManagement.config.method;
BusinessManagement.config.data = JSON2.stringify({
CategoryIsPaid: $('#txtCategoryIsPaid').prop('checked') == true ? "true": "false",
});
BusinessManagement.config.ajaxCallMode = 0;
BusinessManagement.ajaxCall(BusinessManagement.config);
$'txtCategorisPaid'.is':选中“谢谢你,shubham”。这解决了我的问题。顺便说一句,你是尼泊尔人吗?你还可以分享一些链接来解决选择和图像类型的其他类似问题吗?@BibekAryal你想要什么类型的链接。顺便说一句,我不是尼泊尔人。我仍然需要发送html select的值和图像的文件路径。所以我想知道是否有一个网站提供了所有这些信息的集体信息?@BibekAryal如果对你有帮助,请接受这个答案。这对将来的其他人很有用,对此我很抱歉。只是它运行得太快了,stackoverflow不允许我在两分钟内接受答案,我后来完全忘记了
AddCategory: function () {
BusinessManagement.config.method = "AddBusinessCategory";
BusinessManagement.config.url = BusinessManagement.config.baseURL + BusinessManagement.config.method;
BusinessManagement.config.data = JSON2.stringify({
CategoryIsPaid: $('#txtCategoryIsPaid :checked').val(),
});
BusinessManagement.config.ajaxCallMode = 0;
BusinessManagement.ajaxCall(BusinessManagement.config);
<HTML>
<input type="checkbox" id="txtCategoryIsPaid" name="cateogryIsPaid" value="Paid">Yes<br>
Javascript
AddCategory: function () {
BusinessManagement.config.method = "AddBusinessCategory";
BusinessManagement.config.url = BusinessManagement.config.baseURL + BusinessManagement.config.method;
BusinessManagement.config.data = JSON2.stringify({
CategoryIsPaid: $('#txtCategoryIsPaid').prop('checked') == true ? "true": "false",
});
BusinessManagement.config.ajaxCallMode = 0;
BusinessManagement.ajaxCall(BusinessManagement.config);