Post to custom form from React/Ajax


(Mitch Kerry) #1

Matrix Version:
Hi

We’re trying to POST to a custom form from inside a react app running in matrix.
Is this possible?
Have tried via ajax from another page in matrix to no avail.
How do the form elements need to be configured for the POST?

Appreciate assistance
mitch


#2

Try adding another field with name form_email_XXXXX_submit, with the value “Submit”, where XXXXX is the asset id of the form contents asset.


(Mitch Kerry) #3

Thanks…but couldn’t get it to work.

Here is my code:

var oData = new FormData();
oData.append('SQ_FORM_XXXXX_PAGE', '1');
oData.append('form_email_XXXXX_referral_url', '');
oData.append('qXXXXX:q1', '12345');
oData.append('qXXXXX:q2', '46473');
oData.append('form_email_XXXXX_submit', 'Submit');

 $.ajax({
        method: "POST",
        url: 'XXXURI',
        headers: {'Content-Type': 'multipart/form-data;'},
        data: oData,
        processData: false,
        contentType: 'multipart/form-data',
        cache: false

    });

(Mitch Kerry) #4

I solved it…not using $.ajax:

var xhr = new XMLHttpRequest();
xhr.open('POST', 'XXXURL', true);
xhr.send(oData);