【发布时间】:2016-10-06 21:44:57
【问题描述】:
我正在尝试为我的F# controller 创建一个Ajax Post,这样我就可以调用一个方法,该方法将打印和简单的字符串。最终,通过网页上的复选框选择的信息将被插入到数据库中,而不是显示字符串。
我一直在尝试使用this 来提供帮助,但我不太明白。
我现在的 JQuery 代码:
$(document).ready(function () {
$('#Add').click(function () {
var id = [];
$(':checkbox:checked').each(function (i) {
id[i] = $(this).val();
});
if (id.length === 0) {
alert("Please select at least one checkbox")
}
else {
$.post('http://localhost:48214/api/table/?InsertData');
}
console.log();
})
});
我的controller 看起来像这样:
member this.PostInsertData (Insert : string) =
System.Diagnostics.Debug.WriteLine("Called method insert data into table")
Table.insertDataTest
//http://localhost:48214/api/table/?InsertData
//^Link to post request
我的insertDataTest 方法:
let insertDataTest =
System.Diagnostics.Debug.WriteLine("Method Called!")
我通过 Windows 邮递员应用程序知道可以发布帖子,因为我的输出中出现了字符串。 我只是想知道为什么发布请求将通过邮递员而不是通过我的网络 api 工作?
【问题讨论】:
-
你有什么问题?
标签: javascript jquery ajax checkbox f#