Search code examples
javatwitter-bootstrapjspvraptor

How send information from forms without submit modal?


Right now i'm using jsp and bootstrap to make my front-end, and i have an option to make a new register inside a modal and this new register needs to be in my behind screen, in the past projects I used angular and it was very easy to do, but now using jsp I haven't any ideia to make it without submit my modal.

Is there a way to make it without submit my modal?


Solution

  • You can use Ajax, that way you can post the form to back-end to make what you need to do and than return the object to front-end.

    Seeing your tags you're be able to make like that

    Controller:

    @Post
    public void methodName(final T entity) {
        .
        .
        .
        result.use(Results.json()).withoutRoot().from(insertedObject).serialize();
    }
    

    Front:

    $.ajax({
       type : 'POST',
       url : 'method url',
       data : form.serialize(),
       success : function(data){
           // data is the object inserted
       }
    });