Backbone.js getting data on POST request

后端 未结 2 581
醉酒成梦
醉酒成梦 2021-01-22 08:58

I am new to backbone.js.I am trying to POST data with my service and it returns me data. My service is: http://192.168.1.3:8080/app/search/candidate It takes Input

相关标签:
2条回答
  • 2021-01-22 09:21

    By default, Backbone requests media type "application/json", and it looks like your server can't handle that. To work around that, look into emaulateJSON http://backbonejs.org/#Sync-emulateJSON

    0 讨论(0)
  • 2021-01-22 09:41

    This code worked, see the request headers in the console is this jsfiddle :

        this.coll.fetch({
    
            beforeSend: function (xhr) {
                xhr.setRequestHeader('Content-Type', 'application/json');
            },
    
            data: JSON.stringify({'skills':['c','java']}),
    
            type: 'POST',
    
            success: function () {
                //console.log(this.coll.toJSON());
                self.render();
            }
        });
    
    0 讨论(0)
提交回复
热议问题