WordPress-to-lead for Salesforce CRM
AJAX Submission? (6 posts)

  1. devinmcinnis
    Posted 2 years ago #

    Is there a way to implement an AJAX submission where I don't have to refresh the page? I can't seem to find anything built in and I'd rather not manually edit the files because it will probably conflict when the plug-in receives an upgrade.

    Thank you.


  2. Nick Ciske
    Plugin Author

    Posted 2 years ago #

    You could short circuit the form submit with jQuery and submit the data to the Salesforce API yourself via ajax (without touching the core plugin), but it would require some decent coding chops to pull off.

  3. devinmcinnis
    Posted 2 years ago #

    Yeah, I thought about that but couldn't think of a way to do it without exposing the Organization's ID and still be able to work with the plug-in's settings.

    Thanks anyway, Nick.

  4. Nick Ciske
    Plugin Author

    Posted 2 years ago #

    You could call your own AJAX function in WordPress and access that data from the WP options.

    It's a workaround, but if you sent me the code, I may be able to adapt it into a future version.

    Or, feel free to fork it on GitHub and submit a pull request with Ajax baked in ;-)

  5. devinmcinnis
    Posted 2 years ago #

    I've solved this with a simple jQuery POST function:

      var email = $(this).find('#sf_email');
          // These are the fields you are sending
          email: email.val(),
          // Note: these fields are required to validate for Salesforce
          message: '',
        function(data, status, jqXHR){
          // Do something to notify user data has been sent
          console.log(status + ' with status code: ' + jqXHR.status);
        console.log('Oh no! We have failed you.');
      // Stop page from refreshing
      return false;

    Edit: The only problem I've found with this is that is always returns "success" so you will have to validate the form on the client-side before sending. If you want, I could set up a pull request to add type="email" instead of having emails as plain text because SF won't throw errors.

  6. Nick Ciske
    Plugin Author

    Posted 2 years ago #

    Yeah, the Web 2 Lead API is weird like that -- if I remember right it returns an HTTP header/code instead of a message in the body (you can view the plugin code to see how it's handled there).

    How are you passing the organization ID here?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress-to-lead for Salesforce CRM
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic