数据插入成功,但jQuery的仍然返回错误 [英] Data inserted successful but jquery still returning error
问题描述
我用下面的jQuery插入通过数据服务数据。 事件虽然我得到了201状态响应,并将数据成功地插入到我的数据库,系统仍然认为这是一个错误,给我失败的警告?
I used following jQuery to insert a data via Data Service. Event though I got 201 status response and the data is successfully inserted into my database, the system still regard it as a error and give me "failed" alert?
我是怎么在这里失踪。
感谢你在前进
$.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");
}
});
更新: 从火错误调试消息 preferences
UPDATE: Debug Message from Fire Bug Preferences
POST <一href="http://localhost:49223/Form/WebDataService.svc/X...ef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/">http://localhost:49223/Form/WebDataService.svc/X...ef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/
POST <一href="http://localhost:49223/Form/WebDataService.svc/XMLForm(guid%271eaef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/">http://localhost:49223/Form/WebDataService.svc/XMLForm(guid%271eaef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/
jQuery的.... min.js(线127) POST <一href="http://localhost:49223/Form/WebDataService.svc/X...ef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/">http://localhost:49223/Form/WebDataService.svc/X...ef3a0-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 <一href="http://localhost:49223/Form/WebDataService.svc/XMLForm(guid%271eaef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/">http://localhost:49223/Form/WebDataService.svc/XMLForm(guid%271eaef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/
201创建6.7s
201 Created 6.7s
POST <一href="http://localhost:49223/Form/WebDataService.svc/X...ef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/">http://localhost:49223/Form/WebDataService.svc/X...ef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/
POST <一href="http://localhost:49223/Form/WebDataService.svc/XMLForm(guid%271eaef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/">http://localhost:49223/Form/WebDataService.svc/XMLForm(guid%271eaef3a0-d6df-45bf-a8f6-3e7292c0d77e%27)/XMLRecord/
201创建
获取的readyState 4
get readyState 4
获取responseText的{D:{\ r \ N__元...... \')/ XMLForm为\ r \ n}的\ r \ n}的\ r \ n}的}
get responseText "{ "d" : {\r\n"__metadata"...\')/XMLForm"\r\n}\r\n}\r\n} }"
获取responseXML的空
get responseXML null
获取状态201
获取状态文本创建
推荐答案
您必须发送{数据类型:文本}有一个与jQuery和空的成功与否函数工作
You have to send { dataType: 'text' } to have the success function work with jQuery and empty responses.
这篇关于数据插入成功,但jQuery的仍然返回错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!