Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get jQuery post to work with a salesforce WebToLead

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?

like image 440
dibs Avatar asked Feb 26 '10 04:02

dibs


2 Answers

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.

like image 95
Greg Shackles Avatar answered Nov 09 '22 22:11

Greg Shackles


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.

like image 44
dibs Avatar answered Nov 09 '22 23:11

dibs