我想从数据库中检索数据并使用JSON在Checkbox中显示。 [英] I want to retrieve data from database and show in Checkbox using JSON.

查看:107
本文介绍了我想从数据库中检索数据并使用JSON在Checkbox中显示。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从数据库中检索数据并在MVC Razor视图中使用JSON在Checkbox中显示。

然后,我想在MVC Razor视图中使用JSON将复选框的数据保存到数据库。

I want to retrieve data from database and show in Checkbox using JSON in MVC Razor view.
And then, I want to save data of checkbox checked to database using JSON in MVC Razor view.

推荐答案

//use this code this will help you to post the data and get the data is call back function, your action method should return the you databse value.


.ajax({
类型: POST
url: / contrller / Actionmethod
dataType: < span class =code-string> json,
data:{value:seectedvalue}, // oyur chechbox价值
成功:< span class =code-keyword> function (data){
// 指定你的返回您想要的数据
});
},
错误: function (ex){
alert(' 无法检索值。' + ex);
},
});
.ajax({ type: "POST", url: "/contrller/Actionmethod", dataType: "json", data: { value: seectedvalue }, //oyur chechbox value success: function (data) { //assign your return data where you wanto here }); }, error: function (ex) { alert('Failed to retrieve values.' + ex); }, });


这篇关于我想从数据库中检索数据并使用JSON在Checkbox中显示。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆