Reputation: 7953
I am trying to set boolean value to the model attribute as follows :
investAdjustCollection.models[i].set({isUploaded:false});
this creates problem when i send request to server to take some action on the modes data but i get the following exception at the client level
Uncaught SyntaxError: Unexpected token <
and at the server level i get
POST http://localhost:8080/api/trade/createinvestadjust 400 (Bad Request)
if i remove investAdjustCollection.models[i].set({isUploaded:false});
than the server call is made without any issue.
so how to set boolean value true/false in to a bakcbone model.
Upvotes: 0
Views: 1891
Reputation: 146064
First guess is for unknown reasons (validation failed? bug in the server code?), when you send that data, the server throws an exception and instead of responding with a valid JSON response, the response body is an HTML error page with an error message, so when Backbone tries to parse that as JSON, it's invalid. Check your server side logs. Even though they are saying Bad Request, I suspect an exception in the server. However, just to be sure, use the developer tools to examine the headers and body of your PUT request from the browser and make sure the Content-Type is correct and the request body is valid JSON.
Upvotes: 2