$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugins - How to submit custom form data using ajax to HubSpot form?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugins - How to submit custom form data using ajax to HubSpot form?

matteradmin7PV0评论

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.

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.

Share Improve this question asked Oct 29, 2018 at 7:10 Rakesh PatidarRakesh Patidar 433 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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/en-US/docs/Web/HTTP/CORS).

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

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.

Post a comment

comment list (0)

  1. No comments so far