I have a form that I submit to Salesforce with a standard form view. By default, you can tell Salesforce to redirect you to the specified URL after the POST completes.
I no longer want to be redirected, since I have other actions on the form page. No problem, my page already uses jQuery, so I can use the convenient $ .ajax utility, for example:
$('#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!');
},
error:function (xhr, ajaxOptions, thrownError){
console.log(xhr.status);
console.log(thrownError);
}
});
});
In my lost mind, I realized that Salesforce would return my good call forwarding, which would be considered a βsuccess,β which I could simply discard / ignore. Not true!
- I see a 200 OK result (which usually means "success"), but the success callback does not work.
- The listing is added to the Salesforce database.
- ; .
- ( 200 OK), , , - " "? ( 0, thrownError ?).
POST, ? , , , POST, . - .
, , JSONP, , ( , ).