Error saving 400 in Safari

I call save() on the Backbone model. This works in every version of every browser that I have tried except Safari and Safari on iOS.

In these two browsers, the call failed before removing the server with a 400 Bad Request error. The call looks like ../common/User/

My User model is as follows:

 Backbone.Model.extend({ idAttribute: "UserId", initialize: function() { }, url: function () { var base = 'common/User/'; return (this.isNew()) ? base : base + this.id; },... 

The information I'm trying to save is as follows:

 {"BrowserType":"Safari","BrowserVersion":5.1,"ApplicationPath":"index"} 

I do not know what other information I could provide in order to be useful.

Any ideas why this might happen?

EDIT The request header looks like this:

 Accept:application/json, text/javascript, */*; q=0.01 Content-Type:application/json Origin:http://localhost:1087 Referer:http://localhost:1087/index.html User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2 X-Requested-With:XMLHttpRequest 
+4
source share
1 answer

Update the User model url method to include the trailing slash:

 url: function () { var base = 'common/User/'; return (this.isNew()) ? base : base + this.id + "/"; }, 

I had the same problems in my Backbone project - all POST / PUT / PATCH requests for a particular model did not work in Safari and Mobile Safari, although I had no problems in other browsers. Since @mu is too short a comment , adding a trailing slash to my url model method fixes the problem.

+2
source

All Articles