我正在尝试学习Web开发并尝试做一些基本的复选框教程,但我坚持将值发送给Rest Service。
我的意图是,例如,如果选中了两个复选框,我应该能够在我的Rest Service中捕获它并执行某些操作。
下面是HTML文件
$("#btnGetResponse").click(function() { var ids = $('[name="graphId"]:checked').map(function() { return this.id; }).get(); console.log(ids); $.ajax({ type: "GET", url: "https://localhost:51349/SMS_Rest.svc/v1/CheckBox", data: { graphId: ids }, contentType: "application/json; charset=utf-8", dataType: "json", success: function(response) { if (response == true) { alert('hello'); } }, failure: function(response) { alert('fail'); } }); });
如果我选择一个复选框,则生成的URL是:
https://localhost:51349/SMS_Rest.svc/v1/CheckBox?graphId%5B%5D=1
如果我选择TWO复选框,则生成的URL为:
https://localhost:51349/SMS_Rest.svc/v1/CheckBox?graphId%5B%5D=1&graphId%5B%5D=2
我需要在REST中进行哪些更改才能捕获所有选中的复选框。 我应该如何在我的REST服务中捕获它?
rest界面:
Public Interface iSMS_Rest Function CheckBox(ByVal c_Id As Integer) As Boolean End Interface
rest实施:
Public Function CheckBox(ByVal c_Id As Integer) As Boolean Implements iSMS_Rest.CheckBox 'Some Logic If c_Id = 1 Then Return True Else Return False End If End Function
问题:我是否需要更改从HTML文件传递复选框映射值的方式。 或者我需要改变我在UriTemplate捕获请求的方式。 我的UriTemplate是:
请帮我。
以上就是jQuery教程分享无法从复选框向REST传递正确的值相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/jquerytutorial/524304.html