Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
asp.net将多个参数传递给jQuery ajax调用 名字 姓氏 电子邮件 密码 /// $(文档).ready(函数(){ $(“#btnRegister”)。单击(函数(){ 寄存器(); }); 函数寄存器(){ var obj={Firstname:$(“#txtFirstname”).val(),Lastname:$(“#txtLastname”).val(),Email:$(“#txtmail”).val(),密码:$(“#txtPassword”).val(); $.ajax({ 类型:“POST”, contentType:“应用程序/json;字符集=utf-8”, url:“http://localhost:7910/WebService.asmx/Registering", 数据:JSON.stringify(obj), 数据类型:“json”, 成功:功能(数据){ 警报(“成功注册”); }, 错误:函数(数据){ 警报(“错误”); } }); } }); [网络方法] 公共字符串注册(字符串user3gmail、字符串pass3、字符串name3、字符串昵称3、字符串出生) { 返回“{\”registerpacage\”:{\“Id\”:26}”; }_Jquery_Asp.net_Ajax - Fatal编程技术网

asp.net将多个参数传递给jQuery ajax调用 名字 姓氏 电子邮件 密码 /// $(文档).ready(函数(){ $(“#btnRegister”)。单击(函数(){ 寄存器(); }); 函数寄存器(){ var obj={Firstname:$(“#txtFirstname”).val(),Lastname:$(“#txtLastname”).val(),Email:$(“#txtmail”).val(),密码:$(“#txtPassword”).val(); $.ajax({ 类型:“POST”, contentType:“应用程序/json;字符集=utf-8”, url:“http://localhost:7910/WebService.asmx/Registering", 数据:JSON.stringify(obj), 数据类型:“json”, 成功:功能(数据){ 警报(“成功注册”); }, 错误:函数(数据){ 警报(“错误”); } }); } }); [网络方法] 公共字符串注册(字符串user3gmail、字符串pass3、字符串name3、字符串昵称3、字符串出生) { 返回“{\”registerpacage\”:{\“Id\”:26}”; }

asp.net将多个参数传递给jQuery ajax调用 名字 姓氏 电子邮件 密码 /// $(文档).ready(函数(){ $(“#btnRegister”)。单击(函数(){ 寄存器(); }); 函数寄存器(){ var obj={Firstname:$(“#txtFirstname”).val(),Lastname:$(“#txtLastname”).val(),Email:$(“#txtmail”).val(),密码:$(“#txtPassword”).val(); $.ajax({ 类型:“POST”, contentType:“应用程序/json;字符集=utf-8”, url:“http://localhost:7910/WebService.asmx/Registering", 数据:JSON.stringify(obj), 数据类型:“json”, 成功:功能(数据){ 警报(“成功注册”); }, 错误:函数(数据){ 警报(“错误”); } }); } }); [网络方法] 公共字符串注册(字符串user3gmail、字符串pass3、字符串name3、字符串昵称3、字符串出生) { 返回“{\”registerpacage\”:{\“Id\”:26}”; },jquery,asp.net,ajax,Jquery,Asp.net,Ajax,我是Ajax Jquery的初学者,我正在做一些练习来提高我对它的认识。我的问题是,当我单击“重新注册”时,它的“打印错误未成功”消息。我认为我在ajax上传递的参数有问题,但我不知道是什么问题。您正在发送一个具有多个属性的对象。注册方法当前需要多个参数(名称与发送的属性不同)。它应该有一个带有所提供属性的参数——Firstname、Lastname、Email和Password <!DOCTYPE html> <html xmlns="http://www.w3.org/19

我是Ajax Jquery的初学者,我正在做一些练习来提高我对它的认识。我的问题是,当我单击“重新注册”时,它的“打印错误未成功”消息。我认为我在ajax上传递的参数有问题,但我不知道是什么问题。

您正在发送一个具有多个属性的对象。注册方法当前需要多个参数(名称与发送的属性不同)。它应该有一个带有所提供属性的参数——Firstname、Lastname、Email和Password

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="jquery-1.12.0.min.js"></script>
    <script src="Lash.js"></script>
</head>
<body>
   first name <input id="txtFirstname" type="text" /><br />
   last name  <input id="txtLastname" type="text" /><br />
   E-mail     <input id="txtEmail" type="text" /><br />
   password   <input id="txtPassword" type="password" /><br />
    <input id="btnRegister" type="button" value="Register" /><br />
</body>
</html>

/// <reference path="jquery-1.12.0.min.js" />

$(document).ready(function () {

    $("#btnRegister").click(function () {
        Register();
    });

    function Register() {

        var obj = { Firstname: $("#txtFirstname").val(), Lastname: $("#txtLastname").val(), Email: $("#txtEmail").val(), Password: $("#txtPassword").val() };

            $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "http://localhost:7910/WebService.asmx/Registering",
            data:JSON.stringify(obj),
            datatype: "json",
            success: function (data) {
                alert("Successfully register");
            },
                error: function (data) {
                alert("error");
            }

        });

    }

});

 [WebMethod]
        public string Registering(string user3gmail, string pass3, string name3, string nickname3, string birth)
        {
            return "{\"registerPachage\":{\"Id\":26}}";
        }
然后注册方法看起来像

public class RegisterInfo
{
    public string Lastname {get;set;}
    public string Firstname {get;set;}
    public string Password {get;set;}
    public string Email {get;set;}

}

您正在发送具有多个属性的单个对象。注册方法当前需要多个参数(名称与发送的属性不同)。它应该有一个带有所提供属性的参数——Firstname、Lastname、Email和Password

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="jquery-1.12.0.min.js"></script>
    <script src="Lash.js"></script>
</head>
<body>
   first name <input id="txtFirstname" type="text" /><br />
   last name  <input id="txtLastname" type="text" /><br />
   E-mail     <input id="txtEmail" type="text" /><br />
   password   <input id="txtPassword" type="password" /><br />
    <input id="btnRegister" type="button" value="Register" /><br />
</body>
</html>

/// <reference path="jquery-1.12.0.min.js" />

$(document).ready(function () {

    $("#btnRegister").click(function () {
        Register();
    });

    function Register() {

        var obj = { Firstname: $("#txtFirstname").val(), Lastname: $("#txtLastname").val(), Email: $("#txtEmail").val(), Password: $("#txtPassword").val() };

            $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "http://localhost:7910/WebService.asmx/Registering",
            data:JSON.stringify(obj),
            datatype: "json",
            success: function (data) {
                alert("Successfully register");
            },
                error: function (data) {
                alert("error");
            }

        });

    }

});

 [WebMethod]
        public string Registering(string user3gmail, string pass3, string name3, string nickname3, string birth)
        {
            return "{\"registerPachage\":{\"Id\":26}}";
        }
然后注册方法看起来像

public class RegisterInfo
{
    public string Lastname {get;set;}
    public string Firstname {get;set;}
    public string Password {get;set;}
    public string Email {get;set;}

}

我认为您必须传递和代码隐藏方法中相同的参数名称。 见以下代码:

 public string Registering(RegisterInfo register)
        {
            return "{\"registerPachage\":{\"Id\":26}}";
        }

我认为这会有所帮助

我认为您必须传递与代码隐藏方法中相同的参数名称。 见以下代码:

 public string Registering(RegisterInfo register)
        {
            return "{\"registerPachage\":{\"Id\":26}}";
        }

我认为这会有所帮助

您只需传递如下参数

var obj = { user3gmail: 'test1', pass3: 'test1', name3: 'test1', nickname3: 'test1', birth: '232' };
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "Home/Registering",
            data: JSON.stringify(obj),
            datatype: "json",
            success: function (data) {
                alert("Successfully register");
            },
            error: function (data) {
                alert("error");
            }
        });

    public string Registering(string user3gmail, string pass3, string name3, string nickname3, string birth)
            {
               return "{\"registerPachage\":{\"Id\":26}}";
            }
这里我只添加了3个参数,
但您可以添加更多。

您只需传递如下参数

var obj = { user3gmail: 'test1', pass3: 'test1', name3: 'test1', nickname3: 'test1', birth: '232' };
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "Home/Registering",
            data: JSON.stringify(obj),
            datatype: "json",
            success: function (data) {
                alert("Successfully register");
            },
            error: function (data) {
                alert("error");
            }
        });

    public string Registering(string user3gmail, string pass3, string name3, string nickname3, string birth)
            {
               return "{\"registerPachage\":{\"Id\":26}}";
            }
这里我只添加了3个参数,
但是您可以添加更多。

我认为您不需要
JSON.stringify(obj)
,它应该通过简单地将
obj
传递到数据来工作。我认为您不需要
JSON.stringify(obj)
,它应该通过简单地将
obj
传递到数据来工作