'$.ajax - dataType issue with Active Campaign Example Code
I tried this example code from Active Campaign on Github to submit form input to Active Campaign through API - https://github.com/ActiveCampaign/example-add_subscriber_send_instant/blob/master/index.php The problem I am facing is with the JS script at the end.
geturl = $j.ajax({
url: 'test.php', // the URL to this page.
type: 'POST',
//dataType: 'json',
data: form_data,
error: function(jqXHR, textStatus, errorThrown) {
console.log('Error: ' + textStatus);
},
success: function(data) {
$j('#form_result_message').html(data.message);
}
});
The form does not send except I uncomment the dataType: 'json' line. But when I did, I get a parse error even though the form is submitted to Active Campaign. I read on another post that I can try dataType: 'text'. In this case, the parse error is not shown and the form is submitted too.
The problem is that in both instances, the form result message is not displayed and you have to check Active Campaign to find out it has been submitted.
Is there a reason why the code does not work directly as posted on Github? What other solution can I try?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
