PUT on ajax instead of curl



我有这个curl URL连接到couchDB。

curl -X PUT http://admin:ulacit@13.90.93.32:5984/test/"001" -d '{"name":"moises"}'

我看到很多关于GET和POST的问题,但我没有找到PUT的例子。

我这样做的方式是否正确?

$.ajax({
crossOrigin: true,
url : 'http://admin:ulacit@13.90.93.32: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");
}
},

HTTPPUT谓词用于:

  • 创建一个数据库,例如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

最新更新