Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7973489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:07:08+00:00 2026-06-04T08:07:08+00:00

I have a form that I have been submitting to Salesforce with standard form

  • 0

I have a form that I have been submitting to Salesforce with standard form submit action. By default, you can tell Salesforce to redirect you to a given URL after the POST has completed.

I no longer wish to be redirected since I have other activities on the form page. No problem, my page is already using jQuery so I can use the handy $.ajax utility like this:

$('#wrapper').on('click', '#formsubmit', function(e) {
    e.preventDefault();

    var formData = $('#subForm').serialize();
    $.ajax({
      type: "POST",
      url: "https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8",
      data: formData,
      success: function() {
        console.log('success!'); // or not!
      },
      error:function (xhr, ajaxOptions, thrownError){
                    console.log(xhr.status); // 0
                    console.log(thrownError); // empty
                }
    });
});

In my misguided brain, I imagined that Salesforce would return my good ol’ redirect, which would count as a “success” that I can just discard/ignore. Misguided indeed!

  • I can see a 200 OK result (which usually means “success”) but the success callback isn’t tripped.
  • The lead is added to the Salesforce database
  • Inspecting the content of what’s returned shows zero; there is no content in the response.
  • The error callback IS being tripped (despite the 200 OK) but maybe due to intentionally not redirecting it is seen as a “resource not available”? (therefore my status code is 0, and there is no content in the thrownError?).

Any advice on identifying this as a successful POST so that I can trigger additional actions in a callback? I don’t want to TOTALLY ignore the response, or I could end up in a scenario in which I’m acting on a failed POST as if it was successful. I need to capture the success somehow.

It occurred to me that it could be a cross-site scripting issue as well, but since the application doesn’t exchange data in JSONP, I’m not sure how to get around that (and I’m not sure how to identify it in the first place).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:07:12+00:00Added an answer on June 4, 2026 at 8:07 am

    Few things here:

    1) The redirect response being sent by salesforce’s API is most likely being interpreted as an error code.

    2) The response code of the subsequent page (after the redirect) is 200 OK, from the sound of it.

    3) It is not possible to do a POST request using JSONP. This is a limitation of JSONP; which is not actually an AJAX request, but an HTTP GET request wrapped inside of a dynamically generated script tag. Also, JSONP only works if the request yields an HTTP response of 200 OK.

    I would recommend using your own server-side intermediary to handle your AJAX POST request. This will act as a proxy between your front-end app and salesforce’s API. This will also allow you to better control the response being sent to your app.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that I'm submitting through AJAX. The form includes many fields,
I have a form in my MVC application that in theory should submit data
I have been struggling with this for days. I have a form that's a
I have a tell a friend pop up email form that allows users to
I have an Action method in an ASP.NET MVC Controller class that handles form
I'm having an issue submitting a form with jQuery's submit() . I don't have
I currently have form that checks if a user has unsubmitted changes when they
I have a form that I want to be validated before showing it initially.
I have a form that sends money value e.g <input type=text name=amount value=N50,000.00 NGN
I have a form that includes the first name and last name of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.