上ajax而不是卷曲
问题描述:
我有这个卷曲URL连接到couchDB。上ajax而不是卷曲
卷曲-X PUT http://admin:[email protected]:5984/test/ “001” -d '{ “名”: “莫伊塞斯”}'
我看到了很多与GET和POST问题,但我没有找到与PUT的例子。
我这样做是正确的吗?
$.ajax({
crossOrigin: true,
url : 'http://admin:[email protected]:5984/test/'+user,
type : 'POST',
processData: false,
dataType: 'json',
contentType: 'application/json',
data: {pass:pass,email:email},
success:function(result){
if(result!="error"){
alert("Registro Correcto, Proceda a entrar");
open("login.html","_parent");
}else{
alert("Usuario Ya Utilizado");
}
},
答
的PUT
HTTP动词被用来或者:
- 例如创建一个数据库
curl -X PUT http://localhost:5984/mydb
- 当您知道要创建的文档的ID时,在数据库中创建文档,例如,
# create a document with PUT with document id in the URL
curl -X PUT -d '{"a":1,"b":2}' -H 'Content-type: application/json' http://localhost:5984/mydb/mydocid
{"ok":true,"id":"mydocid","rev":"1-25f9b97d75a648d1fcd23f0a73d2776e"}
这是等价的:
# create a document with POST with the document id in the body
curl -X POST -d '{"_id":"mydocid","a":1,"b":2}' -H 'Content-type: application/json' http://localhost:5984/mydb/mydocid