Developer forum

Forum » CMS - Standard features » Submitting UserManagementEditForm with AJAX

Submitting UserManagementEditForm with AJAX

Mikkel Belchuke
Mikkel Belchuke
Reply

Hi. 

I want to submit the form when I change the state of two different checkboxes. It seems to be submitting fine, but does not update the user.

Don't mind the "beautiful" split to get your onsubmit code :) 

$('#check1, #check2').on('change', function () {
       var form = $(this).closest('form');
       var splitFormH = $(form).attr('onsubmit').split("['FormCH1_h'].value='");
        var FormH = splitFormH[1].split("';e.elements['_sys_to_email']");
        var splittedUrl = $(form).attr('onsubmit').split("'action', '");
        var Url = splittedUrl[1].split("');return");

        $('input[name="FormCH1_h"').val(FormH[0])
        $('.js-labels-form').attr('action', Url[0]);
        $('input[name="_sys_to_email"]').val('');

        $.ajax({
            type: form.attr('method'),
            url: form.attr('action'),
            data: form.serialize(),
            success: function (data) {},
            error: function (data) {},
        });
    });


Replies

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

Hi Mikkel,

I try your code on standard template + 2 checkbox.

I get a 404 exception on submit - because form action: action="/Admin/Public/404.aspx"

So I changed your code a little, just use Url variable instead form action:

        $.ajax({
            type: form.attr('method'),
            url: Url[0],
            data: form.serialize(),
            success: function (data) {},
            error: function (data) {},
        });

hmm... I hope that this will help...

Best regards, Vladimir

 

You must be logged in to post in the forum