我有以下Ajax调用方法和asp.net webmethod.
我的asp.net函数在Ajax调用中返回一些我需要的值.
我已经尝试过很多东西,但还没有成功.
AJAX CALL
<script type="text/javascript">
$(document).ready(function () {
// Add the page method call as an onclick handler for the control.
$("#<%=ddlEmailTemplate.ClientID%>").change(function () {
debugger;
var myparam = $("#<%=ddlEmailTemplate.ClientID%>").val(); //id name for dropdown list
$.ajax({
type: "POST",
url: "FileTax.aspx/ddlEmailTemplate_SelectedIndexChanged",
data: '{param:"' + myparam + '"}',
contentType: "application/json; charset=utf-8",
success: function (data) {
alert(data.d)
}
});
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
WebMethod asp.net
答案后更新
[WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
public static string ddlEmailTemplate_SelectedIndexChanged(string param)
{
string subject;
string …Run Code Online (Sandbox Code Playgroud)