hi there
I just can't figure this out.

I have a select element, that when a user chooses "Create", triggers a
modal dialog $("#dialog") with a form retrived from a remote page with
ajax. I don't want to hard code the form in the current page as it can
be called from many pages. This works.
I then capture the submited form with $("#dialog").submit, this works,
but the data is not sent or the ajax call is not made.

Any hints?

// to get the form
$('select[name="medium_id"]').change( function(){
        if(this.value == 'create'){
            $.ajax({
                type: "POST",
                url:  "cell_mediums.php",
                data: "action=input",
                success: function(html){
                    $("#dialog").html(html);
                    $("#dialog").dialog({
                        bgiframe: true,
                        height: 300,
                        width: 400,
                        modal: true
                    });
                }
            });
        }
});

//to send the form values

$("#dialog").submit(function(){

    //testing if triggered
    alert($("#dialog form").serialize());
   // it works

    $.ajax({
        type: "POST",
        url: "cell_mediums.php",
        data: "action=add",
        success: function(html){
            alert(html);
            //nothing returned
        }
    });
});

Reply via email to