[英]Issue with AJAX + vb.net + asp.net
Good morning I have an issue with a AJAX call to a vb.net server side function, my issue is that, never go to server code, I'm begin to be crazy :S 早上好,我对VB.NET服务器端函数的AJAX调用有问题,我的问题是,永远不要去访问服务器代码,我开始变得疯狂:S
scenario: 场景:
Jquery Function: jQuery函数:
<script type="text/javascript">
function notify() {
alert($('#name').val());
alert($('#phone').val());
alert($('#email').val());
alert($('#message').val());
alert('{nombre: ' + $('#name').val() + ', telefono: ' + $('#phone').val() + ', dcorreo: ' + $('#email').val() + ', idea: ' + $('#message').val() + ' }');
$.ajax({
type: "POST",
url: "sendmail.aspx/sendnemail",
data: '{nombre: ' + $('#name').val() + ', telefono: ' + $('#phone').val() + ', dcorreo: ' + $('#email').val() + ', idea: ' + $('#message').val() + ' }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
</script>
I can see all alerts, and the values of field plugged here but, never go to server code 我可以看到所有警报,并且在此处插入了字段的值,但是从来没有去过服务器代码
this is sendmail.aspx.vb: 这是sendmail.aspx.vb:
Imports System.Web.Services
Partial Class sendmail
Inherits System.Web.UI.Page
<WebMethod()>
Public Shared Function sendanemail(ByVal nombre As String, telefono As String, dcorreo As String, idea As String) As String
Return "El mensjae ha sido enviado"
End Function
End Class
sendmail.aspx sendmail.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="sendmail.aspx.vb" Inherits="sendmail" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
Anyone can help me please? 有人可以帮我吗?
I solve this declaring 我解决了这个声明
<script type="text/javascript">
function addanitem(idprod) {
idprod = $("#name").val();
var email = $("#email").val();
var telefono = $("#phone").val();
var message = $("#message").val();
$.ajax({
type: "POST",
url: "carthandler.aspx/SendEmail",
data: '{name: "' + idprod + '", correo: "' + email + '", telefono: "' + telefono + '", idea: "' + message + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
Declaring, variables with the value in field 用字段中的值声明变量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.