Ajax response successful but is triggering the error function
Hey guys,
I have this ajax call:
- $.ajax({
- url: baseUrl + "/concerts",
- type: type,
- contentType: "application/json",
- dataType: "json",
- data: JSON.stringify(jsonConcert),
- async: false,
- crossDomain: true,
- success:function(result) {
- concerts = data;
- },
- error: function(result){
- alert("Error saving concert");
- }
- });
This is the jsonConcert object:
- Object {additionalInfo: "Christian Rock", authorId: 0, date: "04/30/2014", gender: "Rock", id: 12…}
- additionalInfo: "Christian Rock"
- authorId: 0
- date: "04/30/2014"
- gender: "Rock"
- id: 12
- likes: 0
- location: "São Paulo"
- price: "150.00"
- singer: "POD"
- unlikes: 0
- __proto__: Object
But since I'm using JSON.stringfy, this will be the value checked in the server:
- {"additionalInfo":"Christian Rock","authorId":0,"date":"04/30/2014","gender":"Rock","id":12,"likes":0,"location":"São Paulo","price":"150.00","singer":"POD","unlikes":0}
The problem I'm facing is I could save the value in the database, the status.response got was a 200 but some how is the error function is triggered instead of the success. Does anyone have a guess of what is happening ?
Another question is: Should I use stringfy or not in this case ?
Thank you all very much,