Custom Form POST

I would like to have a custom POST action for a form, so that I can use my own Rest API, still having a Divhunt page as a frontend page.

Should I use some jQuery code to change the action and intercept the call?

Is there any best practice that you guys can suggest?

Thanks a lot!

Hi @Paodal

Yes, you can use jQuery for this. Are you using your own REST API directly? Or it will go first tru our system REST API Application?

You need to catch form submission and then prevent default (so the page doesn’t get’s refreshed);

You can use something like this

$(document).on('submit', 'form', function(event) 

    let data = {};
    $.each($(this).serializeArray(), function(index, field) 
       data[] = field.value;

    /* Data is object with all form properties */
   /* SEND YOUR REQUEST HERE USING jQuery FETCH or something */

If you have multiple forms, then set proper ID’s to form, and then use something like

$(document).on('submit', 'form#id-form', function(event)