I have a page with a form that posts to salesforce.com's webto Lead service. I am trying to make an ajax version of this using jQuery.
Though the form in the page posts fine and I receive the data in my salesforce, Once I make an identical post structure to this form and then post with jQuery I get a 405.
Any help with this would be greatly appreciated.
Is there a difference between a posted form and a jquery post as far as what the receiving website can see?
The problem you're running into here is referred to as the same origin policy, which says that XmlHttpRequests must be to the same domain the script is running on. If you need to do this via AJAX, it will need to post to a script running on your domain, which would then make the call out to SalesForce.
To avoid cross domain issues, use ajax to post to a script on your domain that then utilises cURL to make a post to the external domain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With