I've been wrangling with this issue for a day or two so far and I'm not sure I have all the pieces I need to make it work. I'm marginally competent with jquery and OAUTH and all the other parts that go into making AJAX REST calls.

What I need to do is send one small request to SFDC, either a REST APEX class I've built, or the standard REST API to do a PATCH to set a checkbox to false in SFDC based from an external site.

I've looked at the forcetk.js package but can't make any sense of what it's actually doing based on the example.html page. I started by creating series of cUrl commands following the SFDC docs to sort out the OAUTH and my requests. At which point I had a working set of commands that allowed me to get a token and make my request to change this checkbox value correctly. All looked good!

However, now that I've moved onto the next step I'm having all sorts of trouble making a jquery post or ajax request work.

If my cUrl works shouldn't jquery.ajax/post w/the same data also work?

As of now the best I can do is get a CORS error with my $.post() request.

1 Answer 1


You'll need to setup CORS support in your org. See https://help.salesforce.com/HTViewHelpDoc?id=extend_code_cors.htm&language=en_US

  • That makes plenty of sense. But why is it that cUrl requests don't require anything like that? Further, I'm trying to test this stuff out from a local HTML file, not an actual server. Is that even going to be possible?
    – torpy
    May 5, 2015 at 17:38
  • My understanding is that the CORS restriction is only applied to requests made from within the browser (e.g. jQuery AJAX calls). See en.wikipedia.org/wiki/Cross-origin_resource_sharing May 5, 2015 at 17:41
  • I would think it would work with a local HTML file, although you might have to proxy using something like ngrok (ngrok.com) and configure the CORS configuration in your org with the domain provided by ngrok. May 5, 2015 at 17:44
  • 1
    While this hasn't fixed my specific issue I believe it's likely the problem most people will run into. Thanks Artie.
    – torpy
    May 6, 2015 at 19:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .