5 months ago

Re-use section code $.ajax with Jquery Validator

Posted 5 months ago by uicabpatweyler

I'm using the jQuery Validation Plugin (https://jqueryvalidation.org/). I have the following code:

$.validator.setDefaults( {
    submitHandler: function () {
            method: "POST",
            url: urlAction,
            data: $("#myform").serialize()
            .done(function(data, textStatus, jqXHR){
            .fail(function( jqXHR, textStatus, errorThrown){
} );

The above code allows me to create a new element in my table using the POST method. Now, I want to reuse a code in the section to update the element, here is where I have the question, ┬┐How to configure the previous code block so that the method is "PUT" instead of "POST"? I am using Laravel, and apparently to be able to use the "PUT" method, I would have to include the following in my blade file:


Is what I propose possible? Or it is preferable to create another javascript code to perform the data update.

Thanks for your help.

Please sign in or create an account to participate in this conversation.