2
サーバー側からjsonデータを取得できません。スクリプトはサーバーメソッドを呼び出しますが、jsonデータは返されません。あなたは `HTTPを必要といけないjson ajaxリクエストをWeb APIに投稿するには
$(document).ready(function() {
$("#SendMail").click(function() {
$.ajax({
url: "http://localhost:2457/SendMail/SendMail/",
dataType: 'json',
type: 'POST',
data: "{htmlTemplate:" + "ABC" + "}",
//crossDomain: true,
//contentType: "application/json; charset=utf-8",
success: function(data, textStatus, xhr) {
console.log(data);
alert('Successfully called');
},
error: function(xhr, textStatus, errorThrown) {
// console.log(errorThrown);
}
});
});
});
Function SendMail(htmlTemplate As String) As String
Dim fname As String = Request.Form("htmlTemplate1")
Dim lname As String = Request.Form("lname")
Dim cmdSendMail As New SendMailCommand()
Return "A"
End Function
:// localhostを:2457年には、/'唯一のサービス名は、同様に 'webapi'方法を提供 – brk
十分でしょう。 – Venky
WebApiコントローラのデフォルトのルートは、/ api/{Controller}/{Action} –