I used following jQuery to insert data via Data Service.
Event though I got status-response 201 and the data is successfully inserted into my database, the system still regard it as an error and gives me "failed" alert?
What am I missing here?
$.ajax({
type: "POST",
url: "http://localhost:49223/Form/WebDataService.svc/XMLForm(guid'1eaef3a0-d6df-45bf-a8f6-3e7292c0d77e')/XMLRecord/",
data: JSON.stringify(record),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function() {
alert("Success");
},
error: function(xhr) {
alert("fail");
}
});
UPDATE:
Debug Message from Fire Bug:
Preferences
POST http://localhost:49223/Form/WebDataService.svc/X...ef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/
POST http://localhost:49223/Form/WebDataService.svc/XMLForm(guid%271eaef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/
jquery....min.js (line 127)
POST http://localhost:49223/Form/WebDataService.svc/X...ef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/
POST http://localhost:49223/Form/WebDataService.svc/XMLForm(guid%271eaef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/
201 Created 6.7s
POST http://localhost:49223/Form/WebDataService.svc/X...ef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/
POST http://localhost:49223/Form/WebDataService.svc/XMLForm(guid%271eaef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/
201 Created
get readyState 4
get responseText "{ "d" : {
"__metadata"...')/XMLForm"
}
}
} }"
get responseXML null
get status 201
get statusText "Created"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…