I've been following the guide here on making an apex rest call via ajax, but all I get is a status 0 error. http://www.oyecode.com/2014/02/how-to-salesforce-rest-api-from-browser.html
Are there other guides/tutorials on how to make a SOQL query via ajax? What have I done incorrectly?
Here is what I currently have. It shouldn't make a difference, but I'm making this call from htmlservice using google apps script.
$.ajax(
{
type: "GET",
url: "https://na15.salesforce.com/services/data/v26.0/query/?q=SELECT+Name+FROM+Account+LIMIT+5",
beforeSend: function (xhr)
{
xhr.setRequestHeader('Authorization', "Bearer eeeee.xxxxxx");
xhr.setRequestHeader('Accept', "application/json");
xhr.setRequestHeader('dataType', "jsonp");
//usually not needed but when you are
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
xhr.setRequestHeader('Access-Control-Allow-Methods', 'GET');
},
success: function (data)
{
alert(data);
},
error: function(one, two, three)
{
alert(one.status);
alert(two);
alert(three);
}
});