1
私はいくつかの質問を読んだが、私の特定の質問に対する答えはまだ見つからない。私はAjax Postでvb.net subを呼び出そうとしています。 ajax関数は成功を遂げていますが、私のサブスクリプションにブレークポイントを当てたり、実際にデータベースに挿入することはありません。どんな助けもありがとうございます。私のAjaxの機能にcontentType
を追加aspx.vbAjaxが成功を収めたが、VB.Netの機能にぶつからない
<System.Web.Services.WebMethod()> _
Public Shared Sub insertKPI(id As String)
Dim constr As String = ConfigurationManager.ConnectionStrings("SqlServerConnectionString").ConnectionString
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand
cmd.CommandText = "kpi_InsertKPI"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("PartnerLinkCode", HttpContext.Current.Session.Contents("partnerlinkcode").ToString)
cmd.Parameters.AddWithValue("UserLinkCode", HttpContext.Current.Session.Contents("userlinkcode").ToString)
cmd.Parameters.AddWithValue("KPIInfoLinkCode", id)
cmd.Connection = con
con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Using
End Using
End Sub
スクリプト
function addWidget(id){
$.ajax({
type: "POST",
url: "../secure/scorecardtable.aspx/insertKPI",
data: '{"id":' + JSON.stringify(id) + '}',
datatype: "json",
success: function(result){
alert("New kpi should be in database");
console.log(result);
},
error: function(xhr, textStatus, errorThrown){
alert("There was an error inserting the kpi into the database. " + xhr.status + ': ' + errorThrown);
}
}); // End Ajax
}
'.asmx' WebサービスまたはWCFサービス(' .svc')を作成します。 Webページは通常、ajaxリクエストを処理しません。 –