Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Nick Ciske

    (@nickciske)

    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.

    Thread Starter devinmcinnis

    (@devinmcinnis)

    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.

    Plugin Author Nick Ciske

    (@nickciske)

    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 ??
    https://github.com/nciske/salesforce-wordpress-to-lead

    Thread Starter devinmcinnis

    (@devinmcinnis)

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

    $('form').submit(function(){
      var email = $(this).find('#sf_email');
    
      $.post('/halcyon/',
        {
          // These are the fields you are sending
          email: email.val(),
    
          // Note: these fields are required to validate for Salesforce
          message: '',
          form_id:1,
          successmsg:1,
          errormsg:1,
          w2lsubmit:'Join'
        },
        function(data, status, jqXHR){
          // Do something to notify user data has been sent
          email.val('');
          console.log(status + ' with status code: ' + jqXHR.status);
        }
      )
      .fail(function(){
        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.

    Plugin Author Nick Ciske

    (@nickciske)

    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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘AJAX Submission?’ is closed to new replies.