Creating a Grail Jquery Modal Window and Form posting with ajax?

前端 未结 2 2003
谎友^
谎友^ 2021-01-22 16:29

I have the following code :


        
2条回答
  •  被撕碎了的回忆
    2021-01-22 16:59

    Ok Using implementation case 1 is to use ajax and display error or success on the opened dialog :

    So , i have added the following ajax code on above code section ...

    "Attach Comment": function() {
            //do form posting here
            $.ajax({ 
            context: $(this),
            url:"${resource()}"+"/issue/attachComment",
            type:"POST",
            data:{"comment":$('#commentArea').val(),"id":$("#selectedIssueInstanceId").val()},
            success:function(data){
            if(data.success)
            {
            var tobeAppendeID = $("#selectedIssueInstanceId").val();
            $('#'+'comment_'+tobeAppendeID).val(data.newComment);
            $( this ).dialog( "close" );
            }
            else
            {
            $('#error-message').addClass('ui-state-error ui-corner-all');
            $("#error-message").html(data.message).show()
            $(this).dialog("close");
            }
            $( this ).dialog( "close" );
            }
    

提交回复
热议问题