I want to get value from codebehind that then I call it using ajax, but I got nothing, in succes it just show undefine , here the code
function PopMensaje() {
$.ajax({
type: "POST",
url: "/WebForms/Modulo Tramites/ProcesosTramites/frmIniciarTramite.aspx/metodoajax",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
alert("retorno "+result.d);
},
error: function () {
alert('Ocurrio un error');
}
});
on calling show
};
and this the function in codebehind
[WebMethod]
public static string metodoajax(){
return "123";
}
on calling shows "retorno undefine".I expect it shows "retorno 123"
What I'm doing wrong? How to fix this?
You function works fine. I think that your are missing jQuery in your webform and the closing brace for your javascript function:
<head runat="server">
<script src="Scripts/jquery-2.1.4.min.js" type="text/javascript"></script>
</head>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.