我正在向RESTFUL WCF服务应用程序发送一个post请求.我能够POST通过Fiddler 成功发送请求.
但是,当我通过jQuery Ajax方法执行此操作时,该函数会将以下内容返回到Chrome Developer Console:
OPTIONS http://www.example.com/testservice/service1.svc/GetData 405 (Method Not Allowed) jquery.min.js:6
Run Code Online (Sandbox Code Playgroud)
但是之后的第二个日志:
Object {d: "You entered 10"} testpost.html:16
Run Code Online (Sandbox Code Playgroud)
这告诉我的是jQuery正在发送一个OPTIONS请求,该请求失败,然后发送一个POST返回预期数据的请求.
我的jQuery代码:
$.ajax() {
type: "POST", //GET or POST or PUT or DELETE verb
url: "http://www.example.com/testservice/service1.svc/GetData", // Location of the service
data: '{"value":"10"}', //Data sent to server
contentType:"application/json",
dataType: "json", //Expected data format from server
processdata: false,
success: function (msg) {//On Successfull service call
console.log(msg);
},
error: function (xhr) { console.log(xhr.responseText); } // …Run Code Online (Sandbox Code Playgroud) 我正在开发一个项目,其文件路径字段是"一对一"关系(Invoice对象只允许一个文件)或"一对多"关系(一个Claim对象有很多可以添加的文件它).
我目前有两个想法.
1)所有文件的一个数据库
我有一个[索赔]数据库
Claim (PK) --- Name --- Address
1 Joe Some Place
Run Code Online (Sandbox Code Playgroud)
我有[发票]数据库
Invoice (PK) --- Vendor --- FilePathID
100 12 1
Run Code Online (Sandbox Code Playgroud)
还有一个[附件]数据库
UID (PK) --- Claim --- Description --- FilePath
1 NULL Invoice path\to\invoice
2 1 Receipt path\to\receipt
3 1 Image path\to\image
Run Code Online (Sandbox Code Playgroud)
这可以通过以下方式工作:
[Invoice]文件将在[Invoice]对象中明确定义(在本例中为[Attachment] ID 1).然后,文件将通过"附件"数据库中的链接号(上面的情况中的权利要求1)附加到[Claim]对象.这样我们就可以查询列出[Claim] one的所有附件,但同时将[Invoice]文件保存在由文件的UID编号链接的相同[Attachments]数据库中.这允许将所有上载映射到单个数据库中.
我对此方法的唯一关注是,在为[Invoice]上传的文件中,Claim字段保留为NULL.
2)文件路径存储在多个数据库中
这几乎与上面的示例相同,但不是在[Attachments]数据库中链接FilePath,而是直接在[Invoices]数据库中定义.像这样:
我有一个[索赔]数据库
Claim (PK) --- Name --- Address
1 Joe Some Place
Run Code Online (Sandbox Code Playgroud)
我有[发票]数据库
Invoice (PK) --- Vendor --- FilePath
100 12 path\to\invoice
Run Code Online (Sandbox Code Playgroud)
还有一个[附件]数据库
UID (PK) --- …Run Code Online (Sandbox Code Playgroud)