简体   繁体   中英

Get value from ajax loaded page

How can I get the values from the form that is placed in add.php? add.php is a simple file with only one form. Submitting will be done by the following code:

var $addGroup = $('<div></div>')
.load('../view/group/add.php')
.dialog({
    autoOpen: false,
    modal: true,
    title: "Aanmaken groep",
    buttons: {
        "Ok": function() {
            var $groupname = $('#name').val();
            alert($groupname);
            $(this).dialog("close");
        },
        Cancel: function() {
            $(this).dialog("close");
        }
    }
});

I need to get the value $groupname from the field with id 'name'. The current value is undefinied.

Thanks,

$.post('../control/group/add.php', $('#addGroupForm').serialize());

was the solution of course, don't know why I didn't try that

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM