views:

325

answers:

2

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?

+2  A: 

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.

Greg Shackles
Ok so here's how I got it to work.Firstly I ajax a post to a controller on my domain.This then uses cURL to make a post from the domain to the external domain.Viola!
dibs
+1  A: 

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.

dibs