Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • olst 69 posts 88 karma points
    Nov 03, 2011 @ 14:02
    olst
    0

    get data with json in template

    Hi.

    I have the following code, for passing a parameter to a web method, and retrieving a the result in jquery ajax:

    <script type="text/javascript">
            $(document).ready(function () {
                $('#<%=btnSignup.ClientID %>').click(function () {
    
    
                    var dataString = JSON.stringify({
                        firstName: $("#SignupFirstName").val(),
                        lastName: $("#SignupLastName").val(),
                        email: $("#SignupEmail").val(),
                        password: $("#SignupPassword").val()
                    });
    
                    $.getJSON('Signup.aspx/Signup', function (data) {
    
                    });
    
                    $.ajax({
                        type: "POST",
                        url: "Signup.aspx/Signup",
                        data: dataString,
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        async: true,
                        cache: false,
                        beforeSend: function () {
              // some code
                        },
                        success: function (result) {
                            $('#loading').hide();
    
                            if (result.hasOwnProperty("d")) { result = result.d; }//and some more code
                        }
                    });
                    return false;
                });
            });
        </script>

    and the web method:

    [WebMethod]
        public static SignupOutput Signup(string firstName, string lastName, string email, string password)
        {
            // execute some code and return an object for the json
        }

    The method is not executing, I'm using nice urls. Please help, if possible with code or examples.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 03, 2011 @ 22:43
    Jan Skovgaard
    0

    Hi Olst

    I'm not sure what the above error is but I'm thinking that perhaps you could benefit from using the XSLTToJson package? You can get the package here: http://our.umbraco.org/projects/developer-tools/xsltojson

    /Jan

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies