0

I am new in WordPress. I have created a custom form in WordPress. When clicking on the submit button I want to submit form data using ajax to HubSpot. Please, anyone, help me how to complete this task.

0

You can't do it easily. You can send AJAX requests only to the same server your site is on.

To send such request to another server, you'll have to use CORS (https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).

And I don't believe that HubSpot will allow you to set proper headers...

0

You won't be able to do it with AJAX alone for the reason described as above, but you could ajax to your own site and use PHP's cURL to achieve what you want.

Wordpress has an AJAX example you can follow here. All you would do is just set an on submit handler in javascript and fire the ajax request to the PHP function of which would throw that data up using cURL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.