0

From what I understand, I'm able to use my collection to fetch, POST data, to an api. In this case, I'm using the Bing translate api.

My fetch looks like this:

app.searches.fetch({

                    contentType: "application/x-www-form-urlencoded",
                    type: 'POST',
                    data:  { client_id: 'test',client_secret:'test', scope:'http://api.microsofttranslator.com', grant_type: 'client_credentials'},
                    dataType: 'jsonp',

                    success: function () {



                    }
                });

Everytime this fetch fires, it performs a GET, not a POST. Right now, my project is barren so I don't think anything is interfering. Have I written this fetch incorrectly?

EDIT:

here's the collection:

var app = app || {};

(function(){
    'use strict';

    // Searches Collection
    //---------------------

    var Searches = Backbone.Collection.extend({
        //referebce to this collection's model
        model: app.Search,
        url: 'https://datamarket.accesscontrol.windows.net/v2/OAuth2-13'

    });



    app.searches = new Searches();

})();
Adam
  • 8,849
  • 16
  • 67
  • 131
  • It looks right from a glance. – Gohn67 Oct 19 '14 at 02:30
  • it appears dataType: 'jsonp' is causing it to send as GET. If I don't use it, I get "XMLHttpRequest cannot load https://datamarket.accesscontrol.windows.net/v2/OAuth2-13. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8888' is therefore not allowed access. The response had HTTP status code 400. " – Adam Oct 19 '14 at 02:39
  • This link says POST is not allowed for jsonP (I don't use jsonp much at all so am not sure). http://stackoverflow.com/questions/4508198/how-to-use-type-post-in-jsonp-ajax-call – Gohn67 Oct 19 '14 at 02:41
  • Looks like I'll need to build restful service using server-side to obtain the access token rather than using javascript. – Adam Oct 19 '14 at 03:16

0 Answers0